Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
85.71% |
6 / 7 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
SenseId | |
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's sense in the lexicographical data model. |
9 | * |
10 | * @see https://www.mediawiki.org/wiki/Extension:WikibaseLexeme/Data_Model#Sense |
11 | * |
12 | * @license GPL-2.0-or-later |
13 | */ |
14 | class SenseId extends LexemeSubEntityId { |
15 | |
16 | public const PATTERN = '/^L[1-9]\d*-S[1-9]\d*\z/'; |
17 | |
18 | /** |
19 | * @param string $serialization |
20 | */ |
21 | public function __construct( $serialization ) { |
22 | parent::__construct( $serialization ); |
23 | |
24 | Assert::parameter( |
25 | preg_match( self::PATTERN, $this->serialization ), |
26 | '$serialization', |
27 | 'Sense ID must match "' . self::PATTERN . '", given: ' . $this->serialization |
28 | ); |
29 | } |
30 | |
31 | /** |
32 | * @return string |
33 | */ |
34 | public function getEntityType() { |
35 | return Sense::ENTITY_TYPE; |
36 | } |
37 | |
38 | } |