Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| EntitySchemaId | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| getId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare( strict_types = 1 ); |
| 4 | |
| 5 | namespace EntitySchema\Domain\Model; |
| 6 | |
| 7 | use InvalidArgumentException; |
| 8 | |
| 9 | /** |
| 10 | * @license GPL-2.0-or-later |
| 11 | */ |
| 12 | class EntitySchemaId { |
| 13 | |
| 14 | private string $id; |
| 15 | |
| 16 | public const PATTERN = '/^E[1-9][0-9]{0,9}\z/'; |
| 17 | |
| 18 | public function __construct( string $id ) { |
| 19 | if ( !preg_match( self::PATTERN, $id ) ) { |
| 20 | throw new InvalidArgumentException( 'ID must match ' . self::PATTERN ); |
| 21 | } |
| 22 | |
| 23 | $this->id = $id; |
| 24 | } |
| 25 | |
| 26 | public function getId(): string { |
| 27 | return $this->id; |
| 28 | } |
| 29 | |
| 30 | } |