Skip to content

Commit

Permalink
Merge 6fefedc into 97d46b3
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanedev-maroc committed Sep 10, 2016
2 parents 97d46b3 + 6fefedc commit 8e8d0a4
Show file tree
Hide file tree
Showing 14 changed files with 254 additions and 71 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/.idea/
/_arcanedev/
/build/
/vendor/
composer.lock
composer.phar
/composer.lock
/composer.phar
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ checks:

tools:
external_code_coverage:
timeout: 600
timeout: 1200
runs: 12
php_code_sniffer:
enabled: true
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ language: php
sudo: false

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

Expand All @@ -18,6 +17,7 @@ env:
- TESTBENCH_VERSION=3.0.*
- TESTBENCH_VERSION=3.1.*
- TESTBENCH_VERSION=3.2.*
- TESTBENCH_VERSION=3.3.*

before_script:
- travis_retry composer self-update
Expand Down
74 changes: 44 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
# Hasher [![Packagist License][badge_license]](LICENSE.md) [![For Laravel 5][badge_laravel]](https://github.com/ARCANEDEV/Hasher#hasher)
# Hasher [![Packagist License][badge_license]](LICENSE.md) [![For Laravel 5][badge_laravel]][link-github-repo]

[![Travis Status][badge_build]](https://travis-ci.org/ARCANEDEV/Hasher)
[![HHVM Status][badge_hhvm]](http://hhvm.h4cc.de/package/arcanedev/hasher)
[![Coverage Status][badge_coverage]](https://scrutinizer-ci.com/g/ARCANEDEV/Hasher/?branch=master)
[![Scrutinizer Code Quality][badge_quality]](https://scrutinizer-ci.com/g/ARCANEDEV/Hasher/?branch=master)
[![SensioLabs Insight][badge_insight]](https://insight.sensiolabs.com/projects/0c427742-b488-4bff-87ed-cb1d59217d20)
[![Github Issues][badge_issues]](https://github.com/ARCANEDEV/Hasher/issues)
[![Travis Status][badge_build]][link-travis]
[![HHVM Status][badge_hhvm]][link-hhvm]
[![Coverage Status][badge_coverage]][link-scrutinizer]
[![Scrutinizer Code Quality][badge_quality]][link-scrutinizer]
[![SensioLabs Insight][badge_insight]][link-insight]
[![Github Issues][badge_issues]][link-github-issues]

[![Packagist][badge_package]](https://packagist.org/packages/arcanedev/hasher)
[![Packagist Release][badge_release]](https://packagist.org/packages/arcanedev/hasher)
[![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.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
[badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/Hasher.svg?style=flat-square
[badge_quality]: https://img.shields.io/scrutinizer/g/ARCANEDEV/Hasher.svg?style=flat-square
[badge_insight]: https://img.shields.io/sensiolabs/i/0c427742-b488-4bff-87ed-cb1d59217d20.svg?style=flat-square
[badge_issues]: https://img.shields.io/github/issues/ARCANEDEV/Hasher.svg?style=flat-square

[badge_package]: https://img.shields.io/badge/package-arcanedev/hasher-blue.svg?style=flat-square
[badge_release]: https://img.shields.io/packagist/v/arcanedev/hasher.svg?style=flat-square
[badge_downloads]: https://img.shields.io/packagist/dt/arcanedev/hasher.svg?style=flat-square
[![Packagist][badge_package]][link-packagist]
[![Packagist Release][badge_release]][link-packagist]
[![Packagist Downloads][badge_downloads]][link-packagist]

*By [ARCANEDEV©](http://www.arcanedev.net/)*

Expand All @@ -36,6 +22,7 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/Hasher/releas
* Easy setup & configuration.
* Well documented & IDE Friendly.
* Well tested with maximum code quality.
* Laravel `5.0 | 5.1 | 5.2 | 5.3` are supported.
* Made with :heart: & :coffee:.

## Table of contents
Expand All @@ -48,13 +35,40 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/Hasher/releas
## TODOS

- [ ] Complete the documentation.
- [ ] Framework agnostic package.
## DONE

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

## Contribution

Any ideas are welcome. Feel free to submit any issues or pull requests, please check the [contribution guidelines](CONTRIBUTING.md).

## Security

If you discover any security related issues, please email arcanedev.maroc@gmail.com instead of using the issue tracker.

## Credits

- [ARCANEDEV][link-author]
- [All Contributors][link-contributors]

[badge_license]: https://img.shields.io/packagist/l/arcanedev/hasher.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
[badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/Hasher.svg?style=flat-square
[badge_quality]: https://img.shields.io/scrutinizer/g/ARCANEDEV/Hasher.svg?style=flat-square
[badge_insight]: https://img.shields.io/sensiolabs/i/0c427742-b488-4bff-87ed-cb1d59217d20.svg?style=flat-square
[badge_issues]: https://img.shields.io/github/issues/ARCANEDEV/Hasher.svg?style=flat-square

[badge_package]: https://img.shields.io/badge/package-arcanedev/hasher-blue.svg?style=flat-square
[badge_release]: https://img.shields.io/packagist/v/arcanedev/hasher.svg?style=flat-square
[badge_downloads]: https://img.shields.io/packagist/dt/arcanedev/hasher.svg?style=flat-square

[link-author]: https://github.com/arcanedev-maroc
[link-github-repo]: https://github.com/ARCANEDEV/Hasher
[link-github-issues]: https://github.com/ARCANEDEV/Hasher/issues
[link-contributors]: https://github.com/ARCANEDEV/Hasher/graphs/contributors
[link-packagist]: https://packagist.org/packages/arcanedev/hasher
[link-travis]: https://travis-ci.org/ARCANEDEV/Hasher
[link-hhvm]: http://hhvm.h4cc.de/package/arcanedev/hasher
[link-scrutinizer]: https://scrutinizer-ci.com/g/ARCANEDEV/Hasher/?branch=master
[link-insight]: https://insight.sensiolabs.com/projects/0c427742-b488-4bff-87ed-cb1d59217d20
18 changes: 18 additions & 0 deletions _docs/0-Home.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Hasher

The Hasher package provides a flexible hash manager for Laravel.

## Features

* Easy setup & configuration.
* Well documented & IDE Friendly.
* Well tested with maximum code quality.
* Laravel `4.2| 5.0 | 5.1 | 5.2 | 5.3` are supported.
* Made with :heart: & :coffee:.

## Table of contents

1. [Requirements](1-Requirements.md)
3. [Installation and Setup](2-Installation-and-Setup.md)
4. [Configuration](3-Configuration.md)
5. [Usage](4-Usage.md)
17 changes: 17 additions & 0 deletions _docs/1-Requirements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 1. Requirements

## Table of contents

0. [Home](0-Home.md)
1. [Requirements](1-Requirements.md)
2. [Installation and Setup](2-Installation-and-Setup.md)
3. [Configuration](3-Configuration.md)
4. [Usage](4-Usage.md)

## Server Requirements

The Hasher package has a few system requirements:

```
- PHP >= 5.6
```
59 changes: 59 additions & 0 deletions _docs/2-Installation-and-Setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 2. Installation

## Table of contents

0. [Home](0-Home.md)
1. [Requirements](1-Requirements.md)
2. [Installation and Setup](2-Installation-and-Setup.md)
3. [Configuration](3-Configuration.md)
4. [Usage](4-Usage.md)

## Composer

You can install this package via [Composer](http://getcomposer.org/) by running this command: `composer require arcanedev/hasher`.

Or by adding the package to your `composer.json`.

```json
{
"require": {
"arcanedev/hasher": "~1.0"
}
}
```

Then install it via `composer install` or `composer update`.

## Laravel

### Setup

Once the package is installed, you can register the service provider in `config/app.php` in the `providers` array:

```php
// config/app.php

'providers' => [
...
Arcanedev\Hasher\HasherServiceProvider::class,
],
```

(**Optional**) And for the Facades:

```php
// config/app.php

'aliases' => [
...
'Hasher' => Arcanedev\Hasher\Facades\Hasher::class,
];
```

### Artisan commands

To publish the config file, run this command:

```bash
php artisan vendor:publish --provider="Arcanedev\Hasher\HasherServiceProvider"
```
67 changes: 67 additions & 0 deletions _docs/3-Configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# 3. Configuration

## Table of contents

0. [Home](0-Home.md)
1. [Requirements](1-Requirements.md)
2. [Installation and Setup](2-Installation-and-Setup.md)
3. [Configuration](3-Configuration.md)
4. [Usage](4-Usage.md)

After you've published the config file `config/hasher.php`, you can customize the settings :

## Clients

```php
return [
/* ------------------------------------------------------------------------------------------------
| Clients
| ------------------------------------------------------------------------------------------------
*/
'client' => 'hashids',

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

//...
];
```

You can specify the default `client` to use for hashing and also the list of `clients` that are supported with the class associated with.

You can also override the hasher class by replacing the *client value*.

## Connections

```php
return [
// ...

/* ------------------------------------------------------------------------------------------------
| Connections
| ------------------------------------------------------------------------------------------------
*/
'connection' => 'main',

'connections' => [
'hashids' => [
'main' => [
'salt' => '',
'length' => 0,
'alphabet' => '',
],
'alt' => [
'salt' => '',
'length' => 0,
'alphabet' => '',
],
],
],
];
```

The `connection` is the options for the hasher client to use for hashing.

You can specify multiple connections for each client, like `main` and `alt`, it allows you to hash multiple entities in your app with different hashing results.

11 changes: 11 additions & 0 deletions _docs/4-Usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 4. Usage

## Table of contents

0. [Home](0-Home.md)
1. [Requirements](1-Requirements.md)
2. [Installation and Setup](2-Installation-and-Setup.md)
3. [Configuration](3-Configuration.md)
4. [Usage](4-Usage.md)

> Coming soon …
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"type": "library",
"license": "MIT",
"require": {
"php": ">=5.5.9",
"php": ">=5.6",
"arcanedev/support": "~3.0",
"hashids/hashids": "~1.0"
},
Expand Down
7 changes: 4 additions & 3 deletions src/Clients/HashidsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Arcanedev\Hasher\Contracts\HashClient;
use Hashids\Hashids;
use Illuminate\Support\Arr;

/**
* Class HashidsClient
Expand Down Expand Up @@ -46,9 +47,9 @@ public function getClient()
public function make(array $configs)
{
$this->client = new Hashids(
array_get($configs, 'salt', ''),
array_get($configs, 'length', 0),
array_get($configs, 'alphabet', '')
Arr::get($configs, 'salt', ''),
Arr::get($configs, 'length', 0),
Arr::get($configs, 'alphabet', '')
);

return $this;
Expand Down
5 changes: 3 additions & 2 deletions src/Hasher.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php namespace Arcanedev\Hasher;

use Arcanedev\Hasher\Contracts\HashManager;
use Illuminate\Support\Arr;

/**
* Class Hasher
Expand Down Expand Up @@ -66,10 +67,10 @@ public function __construct(array $configs, HasherFactory $factory)
{
$this->factory = $factory;

$this->defaultClient = array_get($configs, 'client', '');
$this->defaultClient = Arr::get($configs, 'client', '');
$this->currentClient = $this->defaultClient;

$this->defaultConnection = array_get($configs, 'connection', '');
$this->defaultConnection = Arr::get($configs, 'connection', '');
$this->currentConnection = $this->defaultConnection;

$this->init();
Expand Down
Loading

0 comments on commit 8e8d0a4

Please sign in to comment.