Total Complexity | 4 |
Total Lines | 28 |
Duplicated Lines | 0 % |
Changes | 5 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class HashidsExtension extends AbstractExtension |
||
12 | { |
||
13 | private HashidsInterface $hashids; |
||
14 | |||
15 | public function __construct(HashidsInterface $hashids) |
||
16 | { |
||
17 | $this->hashids = $hashids; |
||
18 | } |
||
19 | |||
20 | public function getFilters(): array |
||
21 | { |
||
22 | return [ |
||
23 | new TwigFilter('hashids_encode', [$this, 'encode']), |
||
24 | new TwigFilter('hashids_decode', [$this, 'decode']), |
||
25 | ]; |
||
26 | } |
||
27 | |||
28 | public function encode(int $number): string |
||
29 | { |
||
30 | return $this->hashids->encode($number); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * @return array<int, ?int> |
||
35 | */ |
||
36 | public function decode(string $hash): array |
||
39 | } |
||
40 | } |
||
41 |