Skip to content

Commit

Permalink
Merge pull request #11 from ARCANEDEV/update-laravel_5.6_support
Browse files Browse the repository at this point in the history
Adding Laravel 5.6 support
  • Loading branch information
arcanedev-maroc authored Mar 12, 2018
2 parents c7176e4 + dd856db commit 58dfbb8
Show file tree
Hide file tree
Showing 14 changed files with 138 additions and 188 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: php
sudo: false

php:
- 7.0
- 7.1.3
- 7.1
- 7.2
- nightly
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/Hasher/releas
* Flexible hash manager.
* Well documented & IDE Friendly.
* Well tested with maximum code quality.
* Laravel `5.0 | 5.1 | 5.2 | 5.3 | 5.4 | 5.5` are supported.
* Laravel `5.0 | 5.1 | 5.2 | 5.3 | 5.4 | 5.5 | 5.6` are supported.
* Made with :heart: & :coffee:.

## Table of contents
Expand Down
2 changes: 1 addition & 1 deletion _docs/0-Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The Hasher package provides a flexible hash manager for Laravel.
* Flexible hash manager.
* Well documented & IDE Friendly.
* Well tested with maximum code quality.
* Laravel `5.0 | 5.1 | 5.2 | 5.3 | 5.4 | 5.5` are supported.
* Laravel `5.0 | 5.1 | 5.2 | 5.3 | 5.4 | 5.5 | 5.6` are supported.
* Made with :heart: & :coffee:.

## Table of contents
Expand Down
11 changes: 3 additions & 8 deletions _docs/1-Installation-and-Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,27 @@
2. [Configuration](2-Configuration.md)
3. [Usage](3-Usage.md)

## Server Requirements

The Hasher package has a few system requirements:

```
- PHP >= 7.0
```

## Version Compatibility

| Hasher | Laravel |
|:-------------------------------|:--------------------------------------------------------------------------------------------------------------------|
| ![Hasher v2.0.x][hasher_2_0_x] | ![Laravel v5.0][laravel_5_0] ![Laravel v5.1][laravel_5_1] ![Laravel v5.2][laravel_5_2] ![Laravel v5.3][laravel_5_3] |
| ![Hasher v2.1.x][hasher_2_1_x] | ![Laravel v5.4][laravel_5_4] |
| ![Hasher v2.2.x][hasher_2_2_x] | ![Laravel v5.5][laravel_5_5] |
| ![Hasher v2.3.x][hasher_2_3_x] | ![Laravel v5.6][laravel_5_6] |

[laravel_5_0]: https://img.shields.io/badge/v5.0-supported-brightgreen.svg?style=flat-square "Laravel v5.0"
[laravel_5_1]: https://img.shields.io/badge/v5.1-supported-brightgreen.svg?style=flat-square "Laravel v5.1"
[laravel_5_2]: https://img.shields.io/badge/v5.2-supported-brightgreen.svg?style=flat-square "Laravel v5.2"
[laravel_5_3]: https://img.shields.io/badge/v5.3-supported-brightgreen.svg?style=flat-square "Laravel v5.3"
[laravel_5_4]: https://img.shields.io/badge/v5.4-supported-brightgreen.svg?style=flat-square "Laravel v5.4"
[laravel_5_5]: https://img.shields.io/badge/v5.5-supported-brightgreen.svg?style=flat-square "Laravel v5.5"
[laravel_5_6]: https://img.shields.io/badge/v5.6-supported-brightgreen.svg?style=flat-square "Laravel v5.6"

[hasher_2_0_x]: https://img.shields.io/badge/version-2.0.*-blue.svg?style=flat-square "Hasher v2.0.*"
[hasher_2_1_x]: https://img.shields.io/badge/version-2.1.*-blue.svg?style=flat-square "Hasher v2.1.*"
[hasher_2_2_x]: https://img.shields.io/badge/version-2.2.*-blue.svg?style=flat-square "Hasher v2.2.*"
[hasher_2_3_x]: https://img.shields.io/badge/version-2.3.*-blue.svg?style=flat-square "Hasher v2.3.*"

## Composer

Expand Down
58 changes: 24 additions & 34 deletions _docs/2-Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ After you've published the config file `config/hasher.php`, you can customize th

```php
return [
/* ------------------------------------------------------------------------------------------------

/* -----------------------------------------------------------------
| Defaults
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/

'default' => [
'driver' => 'hashids',
'connection' => 'main',
'driver' => 'hashids',
'option' => 'main',
],

//..
Expand All @@ -32,47 +34,35 @@ You can set your default hashing `driver` and `connection` for your application.
return [
//...

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Drivers
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/

'drivers' => [
'hashids' => Arcanedev\Hasher\Drivers\HashidsDriver::class,
],

//...
];
```

The `drivers` attribute allows you to specify the supported drivers for your application and you can also create & add your own custom driver.
'hashids' => [
'driver' => Arcanedev\Hasher\Drivers\HashidsDriver::class,

## Connections
'options' => [
'main' => [
'salt' => env('HASHIDS_MAIN_SALT', ''),
'length' => env('HASHIDS_MAIN_LENGTH', 0),
'alphabet' => env('HASHIDS_MAIN_ALPHABET', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'),
],

```php
return [
// ...

/* ------------------------------------------------------------------------------------------------
| Connections
| ------------------------------------------------------------------------------------------------
*/
'connections' => [
'hashids' => [
'main' => [
'salt' => env('HASHIDS_MAIN_SALT', ''),
'length' => env('HASHIDS_MAIN_LENGTH', 0),
'alphabet' => env('HASHIDS_MAIN_ALPHABET', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'),
//
],
// 'alt' => [
// 'salt' => '',
// 'length' => 0,
// 'alphabet' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890',
// ],
],

],

//...
];
```

The `connections` attribute are options for your hashing driver, it may vary according to your driver.
The `drivers` attribute allows you to specify the supported drivers for your application and you can also create & add your own custom `class` & `options`.

The `options` attribute are options for your hashing driver, it may vary according to your driver.

You can also specify multiple connections for each driver, like `main` and `alt`, it allows you to hash each entity in your application to different hashing results.
63 changes: 27 additions & 36 deletions _docs/3-Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The `driver()` method accepts an argument as the hash driver name. So you can do
$hasher = hasher()->driver('custom-driver');
```

And to get your default driver with different `connection`, you can use the `with()` method for that:
And to get your default driver with different `option`, you can use the `with()` method for that:

```php
$hasher = hasher()->with('alt');
Expand All @@ -79,7 +79,7 @@ You can also use another helper if you don't like calling multiple methods:
$hasher = hash_with('alt');
```

Of course, you can specify the `connection` and the `driver` at the same time with the same helpers:
Of course, you can specify the `option` and the `driver` at the same time with the same helpers:

```php
$hasher = hasher()->with('alt', 'custom-driver');
Expand All @@ -97,11 +97,11 @@ Other useful methods:
// To get your default driver name
$driverName = hasher()->getDefaultDriver();

// To get your default connection name
$connection = hasher()->getDefaultConnection()
// To get your default option name
$option = hasher()->getDefaultOption()

// To set the default connection name
$manager = hasher()->connection('alt');
// To set the default option name
$manager = hasher()->option('alt');
```

## Facade
Expand Down Expand Up @@ -197,7 +197,7 @@ class CustomDriver implements HashDriver
}
```

As you can see, the `__constructor` will receive an array as argument containing the selected `connection` settings.
As you can see, the `__constructor` will receive an array as argument containing the selected `option` settings.

> Check the [HashidsDriver](https://github.com/ARCANEDEV/Hasher/blob/master/src/Drivers/HashidsDriver.php) class as example.
Expand All @@ -209,41 +209,32 @@ After that, you need to add your driver to the supported `drivers` in your `conf
return [
//...

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Drivers
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/

'drivers' => [
'hashids' => Arcanedev\Hasher\Drivers\HashidsDriver::class,
'custom' => App\Hashers\CustomDriver::class
'hashids' => [
'driver' => Arcanedev\Hasher\Drivers\HashidsDriver::class,
'options' => [
'main' => [
'salt' => env('HASHIDS_MAIN_SALT', ''),
'length' => env('HASHIDS_MAIN_LENGTH', 0),
'alphabet' => env('HASHIDS_MAIN_ALPHABET', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'),
],

//
],
],

'custom' => [
'driver' => App\Hashers\CustomDriver::class,
]
],

//...
];
```

This is optional but you can specify a `connection` settings (or multiple) for your `custom` driver:

```php
<?php
return [
//...

/* ------------------------------------------------------------------------------------------------
| Connections
| ------------------------------------------------------------------------------------------------
*/
'connections' => [
'custom' => [
'main' => [
'option-1' => 'value-1',
'option-2' => 'value-2',
//...
],
],
'hashids' => [
//
],
],
];
```
This is optional but you can specify a `option` settings (or multiple) for your `custom` driver.
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
"type": "library",
"license": "MIT",
"require": {
"php": ">=7.0",
"arcanedev/support": "~4.2.0",
"hashids/hashids": "~2.0"
"php": ">=7.1.3",
"arcanedev/support": "~4.3.0",
"hashids/hashids": "~3.0"
},
"require-dev": {
"orchestra/testbench": "~3.5.0",
"phpunit/phpunit": "~6.0",
"phpunit/phpcov": "~4.0"
"orchestra/testbench": "~3.6.0",
"phpunit/phpunit": "~7.0",
"phpunit/phpcov": "~5.0"
},
"autoload": {
"psr-4": {
Expand Down
33 changes: 13 additions & 20 deletions config/hasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/

'default' => [
'driver' => 'hashids',
'connection' => 'main',
'driver' => 'hashids',
'option' => 'main',
],

/* -----------------------------------------------------------------
Expand All @@ -18,28 +18,21 @@
*/

'drivers' => [
'hashids' => Arcanedev\Hasher\Drivers\HashidsDriver::class,
],

/* -----------------------------------------------------------------
| Connections
| -----------------------------------------------------------------
*/

'connections' => [
'hashids' => [
'main' => [
'salt' => env('HASHIDS_MAIN_SALT', ''),
'length' => env('HASHIDS_MAIN_LENGTH', 0),
'alphabet' => env('HASHIDS_MAIN_ALPHABET', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'),
],
'driver' => Arcanedev\Hasher\Drivers\HashidsDriver::class,

'options' => [
'main' => [
'salt' => env('HASHIDS_MAIN_SALT', ''),
'length' => env('HASHIDS_MAIN_LENGTH', 0),
'alphabet' => env('HASHIDS_MAIN_ALPHABET', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'),
],

// 'alt' => [
// 'salt' => '',
// 'length' => 0,
// 'alphabet' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890',
// ],
//
],
],

],

];
6 changes: 3 additions & 3 deletions helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ function hasher()
/**
* Get the Hash Driver instance.
*
* @param string $connection
* @param string $option
* @param string|null $driver
*
* @return \Arcanedev\Hasher\Contracts\HashDriver
*/
function hash_with($connection, $driver = null)
function hash_with($option, $driver = null)
{
return hasher()->with($connection, $driver);
return hasher()->with($option, $driver);
}
}
14 changes: 7 additions & 7 deletions src/Contracts/HashManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ interface HashManager extends HashDriver
public function getDefaultDriver();

/**
* Get the default driver connection.
* Get the default driver option.
*
* @return string
*/
public function getDefaultConnection();
public function getDefaultOption();

/**
* Set the hasher connection.
* Set the hasher option.
*
* @param string $connection
* @param string $option
*
* @return \Arcanedev\Hasher\HashManager
*/
public function connection($connection = null);
public function option($option = null);

/* -----------------------------------------------------------------
| Main Methods
Expand All @@ -45,11 +45,11 @@ public function connection($connection = null);
* Get a driver instance.
*
* @param string $driver
* @param string|null $connection
* @param string|null $option
*
* @return \Arcanedev\Hasher\Contracts\HashDriver
*/
public function with($connection = null, $driver = null);
public function with($option = null, $driver = null);

/**
* Get a driver instance.
Expand Down
Loading

0 comments on commit 58dfbb8

Please sign in to comment.