1 | <?php |
||
21 | class DataValueDeserializer implements DispatchableDeserializer { |
||
22 | |||
23 | const TYPE_KEY = 'type'; |
||
24 | const VALUE_KEY = 'value'; |
||
25 | |||
26 | /** |
||
27 | * @var array Associative array mapping data type IDs to either callables returning new |
||
28 | * DataValue objects, or full qualified DataValue class names. |
||
29 | */ |
||
30 | private $builders; |
||
31 | |||
32 | /** |
||
33 | * @since 0.1, callables are supported since 1.1 |
||
34 | * |
||
35 | * @param array $builders Associative array mapping data type IDs to either callables, or full |
||
36 | * qualified class names. Callables must accept a single value as specified by the |
||
37 | * corresponding DataValue::getArrayValue, and return a new DataValue object. DataValue classes |
||
38 | * given via class name must implement a static newFromArray method doing the same. |
||
39 | */ |
||
40 | 27 | public function __construct( array $builders = [] ) { |
|
44 | |||
45 | 27 | private function assertAreDataValueClasses( array $builders ) { |
|
58 | |||
59 | 26 | private function isDataValueClass( $class ) { |
|
64 | |||
65 | /** |
||
66 | * @see DispatchableDeserializer::isDeserializerFor |
||
67 | * |
||
68 | * @param mixed $serialization |
||
69 | * |
||
70 | * @return bool |
||
71 | */ |
||
72 | 9 | public function isDeserializerFor( $serialization ) { |
|
80 | |||
81 | /** |
||
82 | * @see Deserializer::deserialize |
||
83 | * |
||
84 | * @param array $serialization |
||
85 | * |
||
86 | * @throws DeserializationException |
||
87 | * @return DataValue |
||
88 | */ |
||
89 | 14 | public function deserialize( $serialization ) { |
|
93 | |||
94 | 23 | private function assertCanDeserialize( $serialization ) { |
|
108 | |||
109 | /** |
||
110 | * @param array $serialization |
||
111 | * |
||
112 | * @throws DeserializationException |
||
113 | * @return DataValue |
||
114 | */ |
||
115 | 6 | private function getDeserialization( array $serialization ) { |
|
131 | |||
132 | } |
||
133 |