1 | <?php |
||
17 | class LegacyEntityIdDeserializer implements Deserializer { |
||
18 | |||
19 | /** |
||
20 | * @var EntityIdParser |
||
21 | */ |
||
22 | private $idParser; |
||
23 | |||
24 | public function __construct( EntityIdParser $idParser ) { |
||
27 | |||
28 | /** |
||
29 | * @param string|array $serialization |
||
30 | * |
||
31 | * @return EntityId |
||
32 | * @throws DeserializationException |
||
33 | */ |
||
34 | public function deserialize( $serialization ) { |
||
35 | if ( is_string( $serialization ) ) { |
||
36 | return $this->getParsedId( $serialization ); |
||
37 | } |
||
38 | elseif ( $this->isLegacyFormat( $serialization ) ) { |
||
39 | return $this->getIdFromLegacyFormat( $serialization ); |
||
40 | } |
||
41 | else { |
||
42 | throw new DeserializationException( 'Entity id format not recognized' ); |
||
43 | } |
||
44 | } |
||
45 | |||
46 | private function isLegacyFormat( $serialization ) { |
||
50 | |||
51 | private function getParsedId( $serialization ) { |
||
59 | |||
60 | private function getIdFromLegacyFormat( array $serialization ) { |
||
68 | |||
69 | } |
||
70 |