Move Hashids classes from app/Hashids to app/Services/Hashids

This commit is contained in:
Darko Gjorgjijoski
2026-04-03 15:41:05 +02:00
parent 0ce88ab817
commit e208e3ba56
6 changed files with 27 additions and 27 deletions

View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace App\Services\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']);
}
}