Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
85.71% |
6 / 7 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
FormId | |
85.71% |
6 / 7 |
|
50.00% |
1 / 2 |
2.01 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
getEntityType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Wikibase\Lexeme\Domain\Model; |
4 | |
5 | use Wikimedia\Assert\Assert; |
6 | |
7 | /** |
8 | * Immutable ID of a Lexeme' form in the lexicographical data model. |
9 | * |
10 | * @see https://www.mediawiki.org/wiki/Extension:WikibaseLexeme/Data_Model#Form |
11 | * |
12 | * @license GPL-2.0-or-later |
13 | * @author Thiemo Kreuz |
14 | */ |
15 | class FormId extends LexemeSubEntityId { |
16 | |
17 | public const PATTERN = '/^L[1-9]\d*-F[1-9]\d*\z/'; |
18 | |
19 | /** |
20 | * @param string $serialization |
21 | */ |
22 | public function __construct( $serialization ) { |
23 | parent::__construct( $serialization ); |
24 | |
25 | Assert::parameter( |
26 | preg_match( self::PATTERN, $serialization ), |
27 | '$serialization', |
28 | 'Form ID must match "' . self::PATTERN . '", given: ' . $serialization |
29 | ); |
30 | } |
31 | |
32 | /** |
33 | * @return string |
34 | */ |
35 | public function getEntityType() { |
36 | return Form::ENTITY_TYPE; |
37 | } |
38 | |
39 | } |