Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
Uuid
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 getFunctions
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 getUuid
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getUuidBy
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Engelsystem\Renderer\Twig\Extensions;
6
7use Engelsystem\Helpers\Uuid as UuidHelper;
8use Twig\Extension\AbstractExtension as TwigExtension;
9use Twig\TwigFunction;
10
11class Uuid extends TwigExtension
12{
13    /**
14     * @return TwigFunction[]
15     */
16    public function getFunctions(): array
17    {
18        return [
19            new TwigFunction('uuid', [$this, 'getUuid']),
20            new TwigFunction('uuidBy', [$this, 'getUuidBy']),
21        ];
22    }
23
24    public function getUuid(): string
25    {
26        return UuidHelper::uuid();
27    }
28
29    public function getUuidBy(mixed $value, ?string $name = null): string
30    {
31        return UuidHelper::uuidBy($value, $name);
32    }
33}