| 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 | \Attribute::IS_REPEATABLE), 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
Loading history...
|
|||
| 24 | * @param non-empty-string|null $column Uuid column name |
||
| 25 | * @param bool $nullable Indicates whether to generate a new UUID or not |
||
| 26 | * |
||
| 27 | * @see \Ramsey\Uuid\UuidFactoryInterface::uuid7() |
||
| 28 | */ |
||
| 29 | public function __construct( |
||
| 30 | string $field = 'uuid', |
||
| 31 | ?string $column = null, |
||
| 32 | bool $nullable = false |
||
| 33 | ) { |
||
| 34 | $this->field = $field; |
||
| 35 | $this->column = $column; |
||
| 36 | $this->nullable = $nullable; |
||
| 37 | } |
||
| 38 | |||
| 39 | protected function getListenerClass(): string |
||
| 40 | { |
||
| 41 | return Listener::class; |
||
| 42 | } |
||
| 43 | |||
| 44 | #[ArrayShape(['field' => 'string', 'nullable' => 'bool'])] |
||
| 45 | protected function getListenerArgs(): array |
||
| 46 | { |
||
| 47 | return [ |
||
| 48 | 'field' => $this->field, |
||
| 49 | 'nullable' => $this->nullable |
||
| 50 | ]; |
||
| 51 | } |
||
| 52 | } |
||
| 53 |