Passed
Pull Request — 1.x (#10)
by
unknown
15:02
created

Uuid7::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\ORM\Entity\Behavior\Uuid;
6
7
use Cycle\ORM\Entity\Behavior\Uuid\Listener\Uuid7 as Listener;
8
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
9
use Doctrine\Common\Annotations\Annotation\Target;
10
use JetBrains\PhpStorm\ArrayShape;
11
12
/**
13
 * Uses a version 7 (Unix Epoch Time) UUID
14
 *
15
 * @Annotation
16
 * @NamedArgumentConstructor()
17
 * @Target({"CLASS"})
18
 */
19
#[\Attribute(\Attribute::TARGET_CLASS), NamedArgumentConstructor]
20
final class Uuid7 extends Uuid
21
{
22
    /**
23
     * @param non-empty-string $field Uuid property name
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
24
     * @param non-empty-string|null $column Uuid column name
25
     *
26
     * @see \Ramsey\Uuid\UuidFactoryInterface::uuid7()
27
     */
28
    public function __construct(
29
        string $field = 'uuid',
30
        ?string $column = null
31
    ) {
32
        $this->field = $field;
33
        $this->column = $column;
34
    }
35
36
    protected function getListenerClass(): string
37
    {
38
        return Listener::class;
39
    }
40
41
    #[ArrayShape(['field' => 'string'])]
42
    protected function getListenerArgs(): array
43
    {
44
        return [
45
            'field' => $this->field
46
        ];
47
    }
48
}
49