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 | declare( strict_types = 1 ); |
4 | |
5 | namespace Wikibase\Lexeme\Domain\Model; |
6 | |
7 | use Wikimedia\Assert\Assert; |
8 | |
9 | /** |
10 | * Immutable ID of a Lexeme's sense in the lexicographical data model. |
11 | * |
12 | * @see https://www.mediawiki.org/wiki/Extension:WikibaseLexeme/Data_Model#Sense |
13 | * |
14 | * @license GPL-2.0-or-later |
15 | */ |
16 | class SenseId extends LexemeSubEntityId { |
17 | |
18 | public const PATTERN = '/^L[1-9]\d*-S[1-9]\d*\z/'; |
19 | |
20 | public function __construct( string $serialization ) { |
21 | parent::__construct( $serialization ); |
22 | |
23 | Assert::parameter( |
24 | preg_match( self::PATTERN, $this->serialization ), |
25 | '$serialization', |
26 | 'Sense ID must match "' . self::PATTERN . '", given: ' . $this->serialization |
27 | ); |
28 | } |
29 | |
30 | public function getEntityType(): string { |
31 | return Sense::ENTITY_TYPE; |
32 | } |
33 | |
34 | } |