Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
| TimestampId | |
100.00% |
5 / 5 |
|
100.00% |
5 / 5 |
5 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __toString | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| from | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getValue | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| equals | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | // ╔════════════════════════════════════════════════════════════╗ |
| 4 | // ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║ |
| 5 | // ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com> ║ |
| 6 | // ╚════════════════════════════════════════════════════════════╝ |
| 7 | |
| 8 | declare(strict_types=1); |
| 9 | |
| 10 | namespace Phexium\Domain\Id; |
| 11 | |
| 12 | use Override; |
| 13 | use Stringable; |
| 14 | |
| 15 | final readonly class TimestampId implements Stringable, IdInterface |
| 16 | { |
| 17 | public function __construct(private int $id) {} |
| 18 | |
| 19 | #[Override] |
| 20 | public function __toString(): string |
| 21 | { |
| 22 | return (string) $this->id; |
| 23 | } |
| 24 | |
| 25 | #[Override] |
| 26 | public static function from(int|string $id): self |
| 27 | { |
| 28 | return new self(intval($id)); |
| 29 | } |
| 30 | |
| 31 | #[Override] |
| 32 | public function getValue(): int |
| 33 | { |
| 34 | return $this->id; |
| 35 | } |
| 36 | |
| 37 | #[Override] |
| 38 | public function equals(IdInterface $other): bool |
| 39 | { |
| 40 | return $this->id === $other->getValue(); |
| 41 | } |
| 42 | } |