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 | private $serialization; |
||
33 | |||
34 | /** |
||
35 | * @since 0.1, callables are supported since 1.1 |
||
36 | * |
||
37 | * @param array $builders Associative array mapping data type IDs to either callables, or full |
||
38 | * qualified class names. Callables must accept a single value as specified by the |
||
39 | * corresponding DataValue::getArrayValue, and return a new DataValue object. DataValue classes |
||
40 | * given via class name must implement a static newFromArray method doing the same. |
||
41 | */ |
||
42 | public function __construct( array $builders = array() ) { |
||
46 | |||
47 | private function assertAreDataValueClasses( array $builders ) { |
||
56 | |||
57 | private function isDataValueClass( $class ) { |
||
62 | |||
63 | /** |
||
64 | * @see DispatchableDeserializer::isDeserializerFor |
||
65 | * |
||
66 | * @param mixed $serialization |
||
67 | * |
||
68 | * @return bool |
||
69 | */ |
||
70 | public function isDeserializerFor( $serialization ) { |
||
81 | |||
82 | /** |
||
83 | * @see Deserializer::deserialize |
||
84 | * |
||
85 | * @param mixed $serialization |
||
86 | * |
||
87 | * @throws DeserializationException |
||
88 | * @return DataValue |
||
89 | */ |
||
90 | public function deserialize( $serialization ) { |
||
96 | |||
97 | private function assertCanDeserialize() { |
||
101 | |||
102 | private function assertHasSupportedType() { |
||
111 | |||
112 | private function assertHasValue() { |
||
117 | |||
118 | private function hasSupportedType() { |
||
121 | |||
122 | private function getType() { |
||
125 | |||
126 | /** |
||
127 | * @throws DeserializationException |
||
128 | * @return DataValue |
||
129 | */ |
||
130 | private function getDeserialization() { |
||
143 | |||
144 | private function getValue() { |
||
147 | |||
148 | } |
||
149 |