mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-07 21:44:51 +00:00
Laravel 13 upgrade, updates and fixes
This commit is contained in:
35
app/Hashids/HashidsFactory.php
Normal file
35
app/Hashids/HashidsFactory.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Hashids;
|
||||
|
||||
use Hashids\Hashids;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class HashidsFactory
|
||||
{
|
||||
public function make(array $config): Hashids
|
||||
{
|
||||
$config = $this->getConfig($config);
|
||||
|
||||
return $this->getClient($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{salt: string, length: int, alphabet: string}
|
||||
*/
|
||||
protected function getConfig(array $config): array
|
||||
{
|
||||
return [
|
||||
'salt' => Arr::get($config, 'salt', ''),
|
||||
'length' => Arr::get($config, 'length', 0),
|
||||
'alphabet' => Arr::get($config, 'alphabet', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getClient(array $config): Hashids
|
||||
{
|
||||
return new Hashids($config['salt'], $config['length'], $config['alphabet']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user