Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 1 |
EntitySchemaValue | |
0.00% |
0 / 12 |
|
0.00% |
0 / 9 |
90 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
__serialize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
serialize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
__unserialize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
unserialize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getValue | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getArrayValue | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
getSchemaId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php declare( strict_types=1 ); |
2 | |
3 | namespace EntitySchema\Wikibase\DataValues; |
4 | |
5 | use DataValues\DataValueObject; |
6 | use EntitySchema\Domain\Model\EntitySchemaId; |
7 | use Wikibase\DataModel\Entity\EntityIdValue; |
8 | |
9 | /** |
10 | * @license GPL-2.0-or-later |
11 | */ |
12 | class EntitySchemaValue extends DataValueObject { |
13 | |
14 | public const TYPE = 'entity-schema'; |
15 | |
16 | private EntitySchemaId $id; |
17 | |
18 | public function __construct( EntitySchemaId $id ) { |
19 | $this->id = $id; |
20 | } |
21 | |
22 | public function __serialize(): array { |
23 | return [ 'entityId' => $this->id ]; |
24 | } |
25 | |
26 | /** |
27 | * @inheritDoc |
28 | * Serialization is required by SnakList to compare two snak values |
29 | * by the hash of their serialization. These values are not saved anywhere |
30 | * so Unserialize is never required. |
31 | */ |
32 | public function serialize() { |
33 | return serialize( $this->id ); |
34 | } |
35 | |
36 | /** |
37 | * @param array $data The array representation of the object |
38 | * @return never-returns |
39 | */ |
40 | public function __unserialize( array $data ) { |
41 | throw new \LogicException( 'Method not implemented' ); |
42 | } |
43 | |
44 | /** |
45 | * @param string $data The serialized representation of the object |
46 | * @return never-returns |
47 | */ |
48 | public function unserialize( $data ): void { |
49 | throw new \LogicException( 'Method not implemented' ); |
50 | } |
51 | |
52 | /** @inheritDoc */ |
53 | public static function getType() { |
54 | return EntityIdValue::getType(); |
55 | } |
56 | |
57 | /** @inheritDoc */ |
58 | public function getValue() { |
59 | return $this; |
60 | } |
61 | |
62 | /** @inheritDoc */ |
63 | public function getArrayValue(): array { |
64 | // similar to EntityIdValue::getArrayValue() but without deprecated numeric-id |
65 | return [ |
66 | 'id' => $this->id->getId(), |
67 | 'entity-type' => self::TYPE, |
68 | ]; |
69 | } |
70 | |
71 | public function getSchemaId(): string { |
72 | return $this->id->getId(); |
73 | } |
74 | } |