Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
29 / 29 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
ContextCursorDeserializer | |
100.00% |
29 / 29 |
|
100.00% |
1 / 1 |
6 | |
100.00% |
1 / 1 |
deserialize | |
100.00% |
29 / 29 |
|
100.00% |
1 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Context; |
4 | |
5 | use InvalidArgumentException; |
6 | |
7 | /** |
8 | * A deserializer for {@link ContextCursor}s. |
9 | * |
10 | * @license GPL-2.0-or-later |
11 | */ |
12 | class ContextCursorDeserializer { |
13 | |
14 | public function deserialize( array $serialization ) { |
15 | switch ( $serialization['t'] ) { |
16 | case Context::TYPE_STATEMENT: |
17 | return new MainSnakContextCursor( |
18 | $serialization['i'], |
19 | $serialization['p'], |
20 | $serialization['g'], |
21 | $serialization['h'] |
22 | ); |
23 | case Context::TYPE_QUALIFIER: |
24 | return new QualifierContextCursor( |
25 | $serialization['i'], |
26 | $serialization['p'], |
27 | $serialization['g'], |
28 | $serialization['h'], |
29 | $serialization['P'] |
30 | ); |
31 | case Context::TYPE_REFERENCE: |
32 | return new ReferenceContextCursor( |
33 | $serialization['i'], |
34 | $serialization['p'], |
35 | $serialization['g'], |
36 | $serialization['h'], |
37 | $serialization['P'], |
38 | $serialization['r'] |
39 | ); |
40 | case '\entity': |
41 | return new EntityContextCursor( |
42 | $serialization['i'] |
43 | ); |
44 | default: |
45 | throw new InvalidArgumentException( |
46 | 'Unknown serialization type ' . $serialization['t'] |
47 | ); |
48 | } |
49 | } |
50 | |
51 | } |