Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating the package #1

Merged
merged 10 commits into from
Jan 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
root = true

[*]
end_of_line = crlf
end_of_line = lf
charset = utf-8
indent_style = space
indent_size = 4
Expand Down
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ checks:
tools:
external_code_coverage:
timeout: 600
runs: 3
runs: 12
php_code_sniffer:
enabled: true
config:
Expand Down
13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
language: php

sudo: false

php:
- 5.5.9
- 5.5
- 5.6
- 7.0
- hhvm

sudo: false
env:
- TESTBENCH_VERSION=3.0.*
- TESTBENCH_VERSION=3.1.*
- TESTBENCH_VERSION=3.2.*

before_script:
- travis_retry composer self-update
- travis_retry composer install --prefer-source --no-interaction
- travis_retry composer require --prefer-source --no-interaction --dev "orchestra/testbench:${TESTBENCH_VERSION}"

script:
- composer validate
- mkdir -p build/logs
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover

after_script:
- if [ "$TRAVIS_PHP_VERSION" != "7.0" ] && [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
- if [ "$TRAVIS_PHP_VERSION" != "7.0" ] && [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
- if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
- if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Contributions are welcome, and are accepted via pull requests. Please review the
* Remember that we follow SemVer. If you are changing the behaviour, or the public api, you may need to update the docs.
* Send a coherent commit history, making sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.
* You may also need to rebase to avoid merge conflicts.

## Running Tests

You will need an install of [Composer](https://getcomposer.org) before continuing.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 ARCANEDEV <arcanedev.maroc@gmail.com> - Hasher
Copyright (c) 2015-2016 | ARCANEDEV <arcanedev.maroc@gmail.com> - Hasher

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[![Packagist Downloads][badge_downloads]](https://packagist.org/packages/arcanedev/hasher)

[badge_license]: https://img.shields.io/packagist/l/arcanedev/hasher.svg?style=flat-square
[badge_laravel]: https://img.shields.io/badge/For%20Laravel-5.0%7C5.1-orange.svg?style=flat-square
[badge_laravel]: https://img.shields.io/badge/For%20Laravel-5.x-orange.svg?style=flat-square

[badge_build]: https://img.shields.io/travis/ARCANEDEV/Hasher.svg?style=flat-square
[badge_hhvm]: https://img.shields.io/hhvm/arcanedev/hasher.svg?style=flat-square
Expand Down Expand Up @@ -48,12 +48,12 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/Hasher/releas
## TODOS

- [ ] Complete the documentation.
- [ ] Test Laravel 5.0 support.
- [ ] Framework agnostic package.

## DONE

- [x] Laravel 5.2 supported.
- [x] Laravel 5.1 supported.
- [x] Laravel 5.0 supported.

## Contribution

Expand Down
16 changes: 9 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@
{
"name": "ARCANEDEV",
"email": "arcanedev.maroc@gmail.com",
"homepage": "https://github.com/ARCANEDEV",
"homepage": "https://github.com/arcanedev-maroc",
"role": "Developer"
}
],
"type": "library",
"license": "MIT",
"require": {
"php": ">=5.5.9",
"arcanedev/support": "~3.0",
"hashids/hashids": "~1.0"
"php": ">=5.5.9",
"arcanedev/support": "~3.0",
"hashids/hashids": "~1.0"
},
"require-dev": {
"orchestra/testbench": "~3.1",
"phpunit/phpcov": "~2.0",
"phpunit/phpunit": "~4.0|~5.0"
"phpunit/phpcov": "~2.0|~3.0",
"phpunit/phpunit": "~4.0|~5.0"
},
"autoload": {
"psr-4": {
Expand All @@ -36,6 +35,9 @@
"Arcanedev\\Hasher\\Tests\\": "tests/"
}
},
"scripts": {
"testbench": "composer require --dev \"orchestra/testbench=~3.0\""
},
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
Expand Down
2 changes: 1 addition & 1 deletion config/hasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'client' => 'hashids',

'clients' => [
'hashids' => \Arcanedev\Hasher\Clients\HashidsClient::class,
'hashids' => Arcanedev\Hasher\Clients\HashidsClient::class,
],

/* ------------------------------------------------------------------------------------------------
Expand Down
8 changes: 3 additions & 5 deletions src/Hasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class Hasher implements HashManager
| Properties
| ------------------------------------------------------------------------------------------------
*/
/**
* @var HasherFactory
*/
/** @var \Arcanedev\Hasher\HasherFactory */
protected $factory;

/**
Expand Down Expand Up @@ -61,8 +59,8 @@ class Hasher implements HashManager
/**
* Make Hasher instance.
*
* @param array $configs
* @param HasherFactory $factory
* @param array $configs
* @param \Arcanedev\Hasher\HasherFactory $factory
*/
public function __construct(array $configs, HasherFactory $factory)
{
Expand Down
26 changes: 13 additions & 13 deletions src/HasherFactory.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<?php namespace Arcanedev\Hasher;

use Arcanedev\Hasher\Exceptions\HasherConnectionsException;
use Arcanedev\Hasher\Exceptions\HasherException;
use Arcanedev\Hasher\Exceptions\HasherNotFoundException;

/**
* Class HasherFactory
*
Expand Down Expand Up @@ -75,7 +71,7 @@ private function setConnections(array $connections)
/**
* @param string $client
*
* @return Contracts\HashClient
* @return \Arcanedev\Hasher\Contracts\HashClient
*/
private function getHasherClient($client)
{
Expand Down Expand Up @@ -109,7 +105,7 @@ private function getHasherConnection($client, $connection)
* @param string $client
* @param string $connection
*
* @return Contracts\HashClient
* @return \Arcanedev\Hasher\Contracts\HashClient
*/
public function make($client, $connection = 'main')
{
Expand Down Expand Up @@ -159,16 +155,20 @@ public function registered($client)
*
* @param array $clients
*
* @throws Exceptions\HasherException
* @throws \Arcanedev\Hasher\Exceptions\HasherException
*/
private function checkClients(array &$clients)
{
if (empty($clients)) {
throw new HasherException('You must specify the hasher clients.');
throw new Exceptions\HasherException(
'You must specify the hasher clients.'
);
}

if ( ! $this->isAssoc($clients)) {
throw new HasherException('The hasher clients must be an associative array [name => class].');
throw new Exceptions\HasherException(
'The hasher clients must be an associative array [name => class].'
);
}
}

Expand All @@ -177,12 +177,12 @@ private function checkClients(array &$clients)
*
* @param string $client
*
* @throws Exceptions\HasherNotFoundException
* @throws \Arcanedev\Hasher\Exceptions\HasherNotFoundException
*/
public function checkClient($client)
{
if ( ! $this->registered($client)) {
throw new HasherNotFoundException(
throw new Exceptions\HasherNotFoundException(
"The hasher client [$client] not found."
);
}
Expand All @@ -198,14 +198,14 @@ public function checkClient($client)
private function checkConnections(array $connections)
{
if ( ! $this->isAssoc($connections)) {
throw new HasherConnectionsException(
throw new Exceptions\HasherConnectionsException(
'The hasher connections must be an associative array [key => value].'
);
}

foreach ($connections as $key => $connection) {
if ( ! array_key_exists('main', $connection)) {
throw new HasherConnectionsException(
throw new Exceptions\HasherConnectionsException(
"The hasher [$key] connections must have a [main] connection."
);
}
Expand Down
4 changes: 1 addition & 3 deletions src/HasherServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ public function register()
*/
public function boot()
{
parent::boot();

// Publish the config file.
$this->publishes([
$this->getConfigFile() => config_path("{$this->package}.php"),
Expand Down Expand Up @@ -127,7 +125,7 @@ private function registerHasherService()
return new Hasher($config->get('hasher'), $factory);
});

$this->app->bind(
$this->bind(
\Arcanedev\Hasher\Contracts\HashManager::class,
'arcanedev.hasher'
);
Expand Down
4 changes: 2 additions & 2 deletions tests/Clients/HashidsClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public function setUp()

public function tearDown()
{
parent::tearDown();

unset($this->hasher);

parent::tearDown();
}

/* ------------------------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions tests/HasherFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public function setUp()

public function tearDown()
{
parent::tearDown();

unset($this->hasherFactory);

parent::tearDown();
}

/* ------------------------------------------------------------------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions tests/HasherServiceProviderTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php namespace Arcanedev\Hasher\Tests;

use Arcanedev\Hasher\HasherServiceProvider;

/**
Expand All @@ -13,7 +14,7 @@ class HasherServiceProviderTest extends TestCase
| Properties
| ------------------------------------------------------------------------------------------------
*/
/** @var HasherServiceProvider */
/** @var \Arcanedev\Hasher\HasherServiceProvider */
private $provider;

/* ------------------------------------------------------------------------------------------------
Expand All @@ -29,9 +30,9 @@ public function setUp()

public function tearDown()
{
parent::tearDown();

unset($this->provider);

parent::tearDown();
}

/* ------------------------------------------------------------------------------------------------
Expand Down
14 changes: 9 additions & 5 deletions tests/HasherTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<?php namespace Arcanedev\Hasher\Tests;

use Arcanedev\Hasher\Hasher;

/**
* Class HasherTest
*
* @package Arcanedev\Hasher\Tests
* @author ARCANEDEV <arcanedev.maroc@gmail.com>
*/
class HasherTest extends TestCase
{
/* ------------------------------------------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
*/
/** @var Hasher */
/** @var \Arcanedev\Hasher\Hasher */
private $hasher;

/* ------------------------------------------------------------------------------------------------
Expand All @@ -24,9 +28,9 @@ public function setUp()

public function tearDown()
{
parent::tearDown();

unset($this->hasher);

parent::tearDown();
}

/* ------------------------------------------------------------------------------------------------
Expand Down
11 changes: 8 additions & 3 deletions tests/Stubs/CustomHasherClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
*/
class CustomHasherClient implements HashClient
{
/* ------------------------------------------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
*/
/** @var string */
protected $salt;

/* ------------------------------------------------------------------------------------------------
Expand All @@ -29,7 +34,7 @@ public function getClient()
/**
* Make a new Hash client.
*
* @param array $configs
* @param array $configs
*
* @return self
*/
Expand All @@ -43,7 +48,7 @@ public function make(array $configs)
/**
* Encode the value.
*
* @param mixed $value
* @param mixed $value
*
* @return string
*/
Expand All @@ -66,7 +71,7 @@ public function encode($value)
/**
* Decode the hashed value.
*
* @param string $hash
* @param string $hash
*
* @return mixed
*/
Expand Down