diff --git a/.gitattributes b/.gitattributes index 257d31d..c3ab66e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,12 +1,9 @@ * text=auto eol=lf /tests export-ignore +/.github export-ignore /.editorconfig export-ignore /.gitattributes export-ignore /.gitignore export-ignore -/.styleci.yml export-ignore -/.travis.yml export-ignore /phpunit.xml.dist export-ignore -/CHANGELOG.md export-ignore -/CONTRIBUTING.md export-ignore /README.md export-ignore diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..a99fdc4 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: +- package-ecosystem: composer + directory: "/" + schedule: + interval: weekly + time: "04:00" + open-pull-requests-limit: 10 diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..80273d1 --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,22 @@ +name: PHP-CS-Fixer + +on: + push: + branches: + - master + pull_request: + +jobs: + run: + runs-on: ubuntu-latest + + name: PER-CS + + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: 8.3 + coverage: xdebug + tools: php-cs-fixer, cs2pr + - run: php-cs-fixer fix . --dry-run --rules=@PER-CS --format=checkstyle | cs2pr diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml new file mode 100644 index 0000000..27c66cb --- /dev/null +++ b/.github/workflows/phpunit.yml @@ -0,0 +1,26 @@ +name: PHPUnit + +on: + push: + branches: + - master + pull_request: + +jobs: + run: + runs-on: ubuntu-latest + + strategy: + matrix: + php: [8.2, 8.3, 8.4] + + name: PHP ${{ matrix.php }} + + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: xdebug + - run: composer install --prefer-dist --no-interaction + - run: vendor/bin/phpunit --coverage-text diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index 877e3c4..0000000 --- a/.styleci.yml +++ /dev/null @@ -1,6 +0,0 @@ -enabled: - - unalign_double_arrow - -disabled: - - align_double_arrow - - phpdoc_align diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2b1277c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: php - -php: - - 7.2 - - 7.3 - -install: - - travis_retry composer install --no-interaction - -script: - - vendor/bin/phpunit --coverage-clover clover.xml - -after_script: - - bash <(curl -s https://codecov.io/bash) diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 91cece3..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,95 +0,0 @@ -# CHANGELOG - -## 7.0.0 (released 2019-08-28) - -- Added Laravel 6.0 support -- Dropped Laravel 5.8 support - -## 6.0.0 (released 2019-04-03) - -- Added hashids/hashids 4.0 support -- Removed php 7.1 support - -## 5.2.0 (released 2019-02-27) - -- Added laravel 5.8 support -- Removed laravel 5.7 support - -## 5.1.0 (released 2018-08-23) - -- Added laravel 5.7 support -- Removed laravel 5.6 support - -## 5.0.0 (released 2018-03-12) - -- Added Hashids 3.0 support - -## 4.0.0 (released 2018-02-11) - -- Added Laravel 5.6 support -- Added void return types -- Fixed config when inside phar -- Removed Laravel 5.5 support -- Removed PHP 7.0 support - -## 3.3.0 (released 2017-09-02) - -- Removed Laravel 5.3 and 5.4 support - -## 3.2.0 (released 2017-08-07) - -- Added Laravel 5.5 support - -## 3.1.0 (released 2017-01-01) - -- Added Laravel 5.4 support -- Dropped php 5.6 support - -## 3.0.0 (released 2016-11-15) - -- Updated to hashids 2.0 - -## 2.4.0 (released 2016-07-11) - -- Dropped php 5.5 support - -## 2.3.0 (released 2016-05-05) - -- Added Laravel 5.3 support - -## 2.2.2 (released 2016-01-30) - -- Improved service provider - -## 2.2.1 (released 2016-01-17) - -- Lumen 5.2 support - -## 2.2.0 (released 2015-11-14) - -- Laravel 5.2 support -- Update dependencies - -## 2.1.0 (released 2015-10-07) - -- Improved Lumen support - -## 2.0.1 (released 2015-07-06) - -- Don't require configuration - -## 2.0.0 (released 2015-06-30) - -- Official Lumen support -- Code cleanup -- Moved the factory -- Container binding improvements - -## 1.1.0 (released 2015-05-07) - -- Support both Laravel 5.0 and 5.1 -- Dropped PHP 5.4 support - -## 1.0.0 (released 2015-02-05) - -- Initial stable release diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 7b01d4b..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,28 +0,0 @@ -# Contributing - -Contributions are welcome, and are accepted via pull requests. Please review these guidelines before submitting any pull requests. - -## Guidelines - -- Please follow the [PSR-2 Coding Style Guide](https://www.php-fig.org/psr/psr-2/), enforced by [StyleCI](https://styleci.io). -- Ensure that the current tests pass, and if you've added something new, add the tests where relevant. -- Send a coherent commit history, making sure each individual commit in your pull request is meaningful. -- You may need to [rebase](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) to avoid merge conflicts. -- If you are changing or adding to the behaviour or public API, you may need to update the docs. -- Please remember that we follow [SemVer](https://semver.org). - -## Running Tests - -First, install the dependencies using [Composer](https://getcomposer.org/): - -```sh -$ composer install -``` - -Then run [PHPUnit](https://phpunit.de/): - -```sh -$ vendor/bin/phpunit -``` - -The tests will be automatically run by [Travis CI](https://travis-ci.org/) against pull requests. diff --git a/LICENSE b/LICENSE index c1434b7..ce9d60f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) Vincent Klaiber +Copyright (c) Vincent Klaiber Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/README.md b/README.md index e62c652..b1160a3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# Laravel Hashids - ![hashids](https://cloud.githubusercontent.com/assets/499192/11159205/faa429ae-8a5d-11e5-8c5d-c60a89290c5e.png) +# Laravel Hashids + > A [Hashids](http://hashids.org) bridge for Laravel. ```php @@ -15,24 +15,23 @@ Hashids::decode('1LLb3b4ck'); $hashidsManager->encode(911); ``` -[![Build Status](https://badgen.net/travis/vinkla/laravel-hashids/master)](https://travis-ci.org/vinkla/laravel-hashids) -[![Coverage Status](https://badgen.net/codecov/c/github/vinkla/laravel-hashids)](https://codecov.io/github/vinkla/laravel-hashids) -[![Total Downloads](https://badgen.net/packagist/dt/vinkla/hashids)](https://packagist.org/packages/vinkla/hashids) -[![Latest Version](https://badgen.net/github/release/vinkla/hashids)](https://github.com/vinkla/hashids/releases) -[![License](https://badgen.net/packagist/license/vinkla/hashids)](https://packagist.org/packages/vinkla/hashids) +[![Build Status](https://badgen.net/github/checks/vinkla/laravel-hashids?label=build&icon=github)](https://github.com/vinkla/laravel-hashids/actions) +[![Monthly Downloads](https://badgen.net/packagist/dm/vinkla/hashids)](https://packagist.org/packages/vinkla/hashids/stats) +[![Latest Version](https://badgen.net/packagist/v/vinkla/hashids)](https://packagist.org/packages/vinkla/hashids) + + + Sqids + + +> [!NOTE] +> The creator of Hashids has released a new, upgraded version rebranded as **Sqids**. However, Hashids will continue to be maintained and available for future use. For more information, please visit the [Sqids repository](https://github.com/sqids/sqids-php) and learn how it compares to Hashids on the [Sqids website](https://sqids.org/faq#hashids). **The API is so simple that you don't need a Laravel package at all.** ## Installation Require this package, with [Composer](https://getcomposer.org/), in the root directory of your project. ```bash -$ composer require vinkla/hashids -``` - -If you want you can use the [facade](http://laravel.com/docs/facades). Add the reference in `config/app.php` to your aliases array. - -```php -'Hashids' => Vinkla\Hashids\Facades\Hashids::class +composer require vinkla/hashids ``` ## Configuration @@ -40,7 +39,7 @@ If you want you can use the [facade](http://laravel.com/docs/facades). Add the r Laravel Hashids requires connection configuration. To get started, you'll need to publish all vendor assets: ```bash -$ php artisan vendor:publish +php artisan vendor:publish ``` This will create a `config/hashids.php` file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases. @@ -53,44 +52,30 @@ This option `default` is where you may specify which of the connections below yo This option `connections` is where each of the connections are setup for your application. Example configuration has been included, but you may add as many connections as you would like. - ## Usage -#### HashidsManager - -This is the class of most interest. It is bound to the ioc container as `hashids` and can be accessed using the `Facades\Hashids` facade. This class implements the ManagerInterface by extending AbstractManager. The interface and abstract class are both part of the [Laravel Manager](https://github.com/GrahamCampbell/Laravel-Manager) package, so you may want to go and checkout the docs for how to use the manager class over at that repository. Note that the connection class returned will always be an instance of `Hashids\Hashids`. - -#### Facades\Hashids - -This facade will dynamically pass static method calls to the `hashids` object in the ioc container which by default is the `HashidsManager` class. - -#### HashidsServiceProvider - -This class contains no public methods of interest. This class should be added to the providers array in `config/app.php`. This class will setup ioc bindings. - -### Examples -Here you can see an example of just how simple this package is to use. Out of the box, the default adapter is `main`. After you enter your authentication details in the config file, it will just work: +Here you can see an example of you may use this package. Out of the box, the default adapter is `main`. After you enter your authentication details in the config file, it will just work: ```php // You can alias this in config/app.php. use Vinkla\Hashids\Facades\Hashids; -Hashids::encode(4815162342); // We're done here - how easy was that, it just works! +Hashids::encode(4815162342); -Hashids::decode('doyouthinkthatsairyourebreathingnow'); // This example is simple and there are far more methods available. +Hashids::decode('doyouthinkthatsairyourebreathingnow'); ``` -The Hashids manager will behave like it is a `Hashids\Hashids`. If you want to call specific connections, you can do that with the connection method: +The manager will behave like it is a `Hashids\Hashids` class. If you want to call specific connections, you can do that with the connection method: ```php use Vinkla\Hashids\Facades\Hashids; -// Writing this… +// Writing this... Hashids::connection('main')->encode($id); -// …is identical to writing this +// ...is identical to writing this Hashids::encode($id); // and is also identical to writing this. @@ -103,7 +88,7 @@ Hashids::getDefaultConnection(); // This will return main. Hashids::setDefaultConnection('alternative'); // The default is now alternative. ``` -If you prefer to use dependency injection over facades like me, then you can inject the manager: +If you prefer to use dependency injection over facades, then you can inject the manager: ```php use Vinkla\Hashids\HashidsManager; @@ -119,17 +104,11 @@ class Foo public function bar($id) { - $this->hashids->encode($id) + $this->hashids->encode($id); } } App::make('Foo')->bar(); ``` -## Documentation - -There are other classes in this package that are not documented here. This is because the package is a Laravel wrapper of [Ivan Akimov's](https://github.com/ivanakimov) [Hashids package](https://github.com/ivanakimov/hashids.php#readme). - -## License - -[MIT](LICENSE) © [Vincent Klaiber](https://doubledip.se) +For more information on how to use the `Hashids\Hashids` class, check out the docs at [`hashids/hashids`](https://github.com/vinkla/hashids.php). diff --git a/composer.json b/composer.json index 341d76d..7aaa987 100644 --- a/composer.json +++ b/composer.json @@ -1,55 +1,32 @@ { "name": "vinkla/hashids", "description": "A Hashids bridge for Laravel", + "license": "MIT", "keywords": [ - "laravel", "hashids", - "hashid", - "hash", - "ids", - "youtube", - "bitly", - "encrypt", - "decrypt", - "obfuscate" + "laravel" ], - "license": "MIT", "authors": [ { "name": "Vincent Klaiber", - "email": "hello@doubledip.se", - "homepage": "https://doubledip.se/" + "homepage": "https://github.com/vinkla" } ], "require": { - "php": "^7.2", - "graham-campbell/manager": "^4.3", - "hashids/hashids": "^4.0", - "illuminate/contracts": "^6.0", - "illuminate/support": "^6.0" + "php": "^8.2", + "graham-campbell/manager": "^5.2", + "hashids/hashids": "^5.0", + "illuminate/contracts": "^12.0", + "illuminate/support": "^12.0" }, "require-dev": { - "graham-campbell/analyzer": "^2.3", - "graham-campbell/testbench": "^5.3", - "mockery/mockery": "^1.2", - "phpunit/phpunit": "^8.0" - }, - "config": { - "preferred-install": "dist" - }, - "extra": { - "branch-alias": { - "dev-master": "7.0-dev" - }, - "laravel": { - "providers": [ - "Vinkla\\Hashids\\HashidsServiceProvider" - ], - "aliases": { - "Hashids": "Vinkla\\Hashids\\Facades\\Hashids" - } - } + "graham-campbell/analyzer": "^5.0", + "graham-campbell/testbench": "^6.1", + "mockery/mockery": "^1.6.6", + "phpunit/phpunit": "^11.5 || ^12.1" }, + "minimum-stability": "dev", + "prefer-stable": true, "autoload": { "psr-4": { "Vinkla\\Hashids\\": "src/" @@ -60,6 +37,17 @@ "Vinkla\\Tests\\Hashids\\": "tests/" } }, - "minimum-stability": "dev", - "prefer-stable": true + "config": { + "preferred-install": "dist" + }, + "extra": { + "laravel": { + "aliases": { + "Hashids": "Vinkla\\Hashids\\Facades\\Hashids" + }, + "providers": [ + "Vinkla\\Hashids\\HashidsServiceProvider" + ] + } + } } diff --git a/config/hashids.php b/config/hashids.php index f8d4d1e..1c271a5 100644 --- a/config/hashids.php +++ b/config/hashids.php @@ -1,16 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -declare(strict_types=1); - return [ /* @@ -40,13 +29,15 @@ 'connections' => [ 'main' => [ - 'salt' => 'your-salt-string', - 'length' => 'your-length-integer', + 'salt' => '', + 'length' => 0, + // 'alphabet' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' ], 'alternative' => [ 'salt' => 'your-salt-string', 'length' => 'your-length-integer', + // 'alphabet' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' ], ], diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 10f462a..c13aa67 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,29 +1,13 @@ - - - - ./tests - - - - - ./src - - + + + + ./tests + + + + + ./src + + diff --git a/src/Facades/Hashids.php b/src/Facades/Hashids.php index 80b2037..2db07ac 100644 --- a/src/Facades/Hashids.php +++ b/src/Facades/Hashids.php @@ -1,12 +1,12 @@ +/** + * Copyright (c) Vincent Klaiber * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @see https://github.com/vinkla/laravel-hashids */ declare(strict_types=1); @@ -16,22 +16,14 @@ use Illuminate\Support\Facades\Facade; /** - * This is the Hashids facade class. - * - * @author Vincent Klaiber - * - * @method static string encode(mixed ...$numbers) Encode parameters to generate a hash. - * @method static array decode(string $hash) Decode a hash to the original parameter values. - * @method static string encodeHex(string $str) Encode hexadecimal values and generate a hash string. - * @method static string decodeHex(string $hash) Decode a hexadecimal hash. + * @method static string encode(mixed ...$numbers) + * @method static array decode(string $hash) + * @method static string encodeHex(string $str) + * @method static string decodeHex(string $hash) + * @method static \Hashids\Hashids connection(string|null $name = null) */ class Hashids extends Facade { - /** - * Get the registered name of the component. - * - * @return string - */ protected static function getFacadeAccessor(): string { return 'hashids'; diff --git a/src/HashidsFactory.php b/src/HashidsFactory.php index c082f0b..44283bd 100644 --- a/src/HashidsFactory.php +++ b/src/HashidsFactory.php @@ -1,12 +1,12 @@ +/** + * Copyright (c) Vincent Klaiber * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @see https://github.com/vinkla/laravel-hashids */ declare(strict_types=1); @@ -16,20 +16,8 @@ use Hashids\Hashids; use Illuminate\Support\Arr; -/** - * This is the Hashids factory class. - * - * @author Vincent Klaiber - */ class HashidsFactory { - /** - * Make a new Hashids client. - * - * @param array $config - * - * @return \Hashids\Hashids - */ public function make(array $config): Hashids { $config = $this->getConfig($config); @@ -37,15 +25,6 @@ public function make(array $config): Hashids return $this->getClient($config); } - /** - * Get the configuration data. - * - * @param array $config - * - * @throws \InvalidArgumentException - * - * @return array - */ protected function getConfig(array $config): array { return [ @@ -55,13 +34,6 @@ protected function getConfig(array $config): array ]; } - /** - * Get the hashids client. - * - * @param array $config - * - * @return \Hashids\Hashids - */ protected function getClient(array $config): Hashids { return new Hashids($config['salt'], $config['length'], $config['alphabet']); diff --git a/src/HashidsManager.php b/src/HashidsManager.php index 3f27676..f9bac46 100644 --- a/src/HashidsManager.php +++ b/src/HashidsManager.php @@ -1,12 +1,12 @@ +/** + * Copyright (c) Vincent Klaiber * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @see https://github.com/vinkla/laravel-hashids */ declare(strict_types=1); @@ -18,32 +18,15 @@ use Illuminate\Contracts\Config\Repository; /** - * This is the Hashids manager class. - * - * @method string encode(mixed ...$numbers) Encode parameters to generate a hash. - * @method array decode(string $hash) Decode a hash to the original parameter values. - * @method string encodeHex(string $str) Encode hexadecimal values and generate a hash string. - * @method string decodeHex(string $hash) Decode a hexadecimal hash. - * - * @author Vincent Klaiber + * @method string encode(mixed ...$numbers) + * @method array decode(string $hash) + * @method string encodeHex(string $str) + * @method string decodeHex(string $hash) */ class HashidsManager extends AbstractManager { - /** - * The factory instance. - * - * @var \Vinkla\Hashids\HashidsFactory - */ - protected $factory; + protected HashidsFactory $factory; - /** - * Create a new Hashids manager instance. - * - * @param \Illuminate\Contracts\Config\Repository $config - * @param \Vinkla\Hashids\HashidsFactory $factory - * - * @return void - */ public function __construct(Repository $config, HashidsFactory $factory) { parent::__construct($config); @@ -51,33 +34,16 @@ public function __construct(Repository $config, HashidsFactory $factory) $this->factory = $factory; } - /** - * Create the connection instance. - * - * @param array $config - * - * @return \Hashids\Hashids - */ protected function createConnection(array $config): Hashids { return $this->factory->make($config); } - /** - * Get the configuration name. - * - * @return string - */ protected function getConfigName(): string { return 'hashids'; } - /** - * Get the factory instance. - * - * @return \Vinkla\Hashids\HashidsFactory - */ public function getFactory(): HashidsFactory { return $this->factory; diff --git a/src/HashidsServiceProvider.php b/src/HashidsServiceProvider.php index 404e8df..7869642 100644 --- a/src/HashidsServiceProvider.php +++ b/src/HashidsServiceProvider.php @@ -1,12 +1,12 @@ +/** + * Copyright (c) Vincent Klaiber * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @see https://github.com/vinkla/laravel-hashids */ declare(strict_types=1); @@ -15,50 +15,24 @@ use Hashids\Hashids; use Illuminate\Contracts\Container\Container; -use Illuminate\Foundation\Application as LaravelApplication; use Illuminate\Support\ServiceProvider; -use Laravel\Lumen\Application as LumenApplication; -/** - * This is the Hashids service provider class. - * - * @author Vincent Klaiber - */ class HashidsServiceProvider extends ServiceProvider { - /** - * Boot the service provider. - * - * @return void - */ public function boot(): void { $this->setupConfig(); } - /** - * Setup the config. - * - * @return void - */ protected function setupConfig(): void { - $source = realpath($raw = __DIR__.'/../config/hashids.php') ?: $raw; + $source = realpath($raw = __DIR__ . '/../config/hashids.php') ?: $raw; - if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) { - $this->publishes([$source => config_path('hashids.php')]); - } elseif ($this->app instanceof LumenApplication) { - $this->app->configure('hashids'); - } + $this->publishes([$source => config_path('hashids.php')]); $this->mergeConfigFrom($source, 'hashids'); } - /** - * Register the service provider. - * - * @return void - */ public function register(): void { $this->registerFactory(); @@ -66,11 +40,6 @@ public function register(): void $this->registerBindings(); } - /** - * Register the factory class. - * - * @return void - */ protected function registerFactory(): void { $this->app->singleton('hashids.factory', function () { @@ -80,11 +49,6 @@ protected function registerFactory(): void $this->app->alias('hashids.factory', HashidsFactory::class); } - /** - * Register the manager class. - * - * @return void - */ protected function registerManager(): void { $this->app->singleton('hashids', function (Container $app) { @@ -97,11 +61,6 @@ protected function registerManager(): void $this->app->alias('hashids', HashidsManager::class); } - /** - * Register the bindings. - * - * @return void - */ protected function registerBindings(): void { $this->app->bind('hashids.connection', function (Container $app) { @@ -113,11 +72,6 @@ protected function registerBindings(): void $this->app->alias('hashids.connection', Hashids::class); } - /** - * Get the services provided by the provider. - * - * @return string[] - */ public function provides(): array { return [ diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index b424ceb..34bd9cc 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -1,12 +1,12 @@ +/** + * Copyright (c) Vincent Klaiber * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @see https://github.com/vinkla/laravel-hashids */ declare(strict_types=1); @@ -16,21 +16,9 @@ use GrahamCampbell\TestBench\AbstractPackageTestCase; use Vinkla\Hashids\HashidsServiceProvider; -/** - * This is the abstract test class. - * - * @author Vincent Klaiber - */ abstract class AbstractTestCase extends AbstractPackageTestCase { - /** - * Get the service provider class. - * - * @param \Illuminate\Contracts\Foundation\Application $app - * - * @return string - */ - protected function getServiceProviderClass($app) + protected static function getServiceProviderClass(): string { return HashidsServiceProvider::class; } diff --git a/tests/AnalysisTest.php b/tests/AnalysisTest.php index b3bbb6f..13fae81 100644 --- a/tests/AnalysisTest.php +++ b/tests/AnalysisTest.php @@ -1,12 +1,12 @@ +/** + * Copyright (c) Vincent Klaiber * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @see https://github.com/vinkla/laravel-hashids */ declare(strict_types=1); @@ -14,39 +14,18 @@ namespace Vinkla\Tests\Hashids; use GrahamCampbell\Analyzer\AnalysisTrait; -use Laravel\Lumen\Application; use PHPUnit\Framework\TestCase; -/** - * This is the analysis test class. - * - * @author Vincent Klaiber - */ class AnalysisTest extends TestCase { use AnalysisTrait; - /** - * Get the code paths to analyze. - * - * @return string[] - */ - protected function getPaths() + protected static function getPaths(): array { return [ - realpath(__DIR__.'/../config'), - realpath(__DIR__.'/../src'), + realpath(__DIR__ . '/../config'), + realpath(__DIR__ . '/../src'), realpath(__DIR__), ]; } - - /** - * Get the classes to ignore not existing. - * - * @return string[] - */ - protected function getIgnored() - { - return [Application::class]; - } } diff --git a/tests/Facades/HashidsTest.php b/tests/Facades/HashidsTest.php index f102d24..24d52c6 100644 --- a/tests/Facades/HashidsTest.php +++ b/tests/Facades/HashidsTest.php @@ -1,12 +1,12 @@ +/** + * Copyright (c) Vincent Klaiber * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @see https://github.com/vinkla/laravel-hashids */ declare(strict_types=1); @@ -18,41 +18,21 @@ use Vinkla\Hashids\HashidsManager; use Vinkla\Tests\Hashids\AbstractTestCase; -/** - * This is the Hashids facade test class. - * - * @author Vincent Klaiber - */ class HashidsTest extends AbstractTestCase { use FacadeTrait; - /** - * Get the facade accessor. - * - * @return string - */ - protected function getFacadeAccessor() + protected static function getFacadeAccessor(): string { return 'hashids'; } - /** - * Get the facade class. - * - * @return string - */ - protected function getFacadeClass() + protected static function getFacadeClass(): string { return Hashids::class; } - /** - * Get the facade root. - * - * @return string - */ - protected function getFacadeRoot() + protected static function getFacadeRoot(): string { return HashidsManager::class; } diff --git a/tests/HashidsFactoryTest.php b/tests/HashidsFactoryTest.php index 77a2c15..2cba979 100644 --- a/tests/HashidsFactoryTest.php +++ b/tests/HashidsFactoryTest.php @@ -1,12 +1,12 @@ +/** + * Copyright (c) Vincent Klaiber * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @see https://github.com/vinkla/laravel-hashids */ declare(strict_types=1); @@ -16,27 +16,22 @@ use Hashids\Hashids; use Vinkla\Hashids\HashidsFactory; -/** - * This is the Hashids factory test class. - * - * @author Vincent Klaiber - */ class HashidsFactoryTest extends AbstractTestCase { - public function testMakeStandard() + public function testMakeStandard(): void { $factory = $this->getHashidsFactory(); $return = $factory->make([ 'salt' => 'your-salt-string', - 'length' => 'your-length-integer', + 'length' => 0, 'alphabet' => 'your-alphabet-string', ]); $this->assertInstanceOf(Hashids::class, $return); } - protected function getHashidsFactory() + protected function getHashidsFactory(): HashidsFactory { return new HashidsFactory(); } diff --git a/tests/HashidsManagerTest.php b/tests/HashidsManagerTest.php index 90b6a2f..3d773b5 100644 --- a/tests/HashidsManagerTest.php +++ b/tests/HashidsManagerTest.php @@ -1,12 +1,12 @@ +/** + * Copyright (c) Vincent Klaiber * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @see https://github.com/vinkla/laravel-hashids */ declare(strict_types=1); @@ -20,14 +20,9 @@ use Vinkla\Hashids\HashidsFactory; use Vinkla\Hashids\HashidsManager; -/** - * This is the Hashids manager test class. - * - * @author Vincent Klaiber - */ class HashidsManagerTest extends AbstractTestBenchTestCase { - public function testCreateConnection() + public function testCreateConnection(): void { $config = ['path' => __DIR__]; @@ -45,7 +40,7 @@ public function testCreateConnection() $this->assertArrayHasKey('hashids', $manager->getConnections()); } - protected function getManager(array $config) + protected function getManager(array $config): HashidsManager { $repository = Mockery::mock(Repository::class); $factory = Mockery::mock(HashidsFactory::class); diff --git a/tests/ServiceProviderTest.php b/tests/ServiceProviderTest.php index 23f9bb1..7409535 100644 --- a/tests/ServiceProviderTest.php +++ b/tests/ServiceProviderTest.php @@ -1,12 +1,12 @@ +/** + * Copyright (c) Vincent Klaiber * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. + * + * @see https://github.com/vinkla/laravel-hashids */ declare(strict_types=1); @@ -18,26 +18,21 @@ use Vinkla\Hashids\HashidsFactory; use Vinkla\Hashids\HashidsManager; -/** - * This is the service provider test class. - * - * @author Vincent Klaiber - */ class ServiceProviderTest extends AbstractTestCase { use ServiceProviderTrait; - public function testHashidsFactoryIsInjectable() + public function testHashidsFactoryIsInjectable(): void { $this->assertIsInjectable(HashidsFactory::class); } - public function testHashidsManagerIsInjectable() + public function testHashidsManagerIsInjectable(): void { $this->assertIsInjectable(HashidsManager::class); } - public function testBindings() + public function testBindings(): void { $this->assertIsInjectable(Hashids::class);