Exemplo n.º 1
0
 /**
  * @param array $serializedObject
  *
  * @return object
  */
 private function deserializeObject(array $serializedObject)
 {
     list($name, $payload) = $this->dataFormatter->getNameAndPayload($serializedObject);
     $curatedPayload = [];
     foreach ($payload as $key => $value) {
         $curatedPayload[$key] = $this->recursiveDeserialize($value);
     }
     $objectFqcn = $this->classMapper->getClassName($name);
     foreach ($this->customSerializers as $customSerializer) {
         if ($customSerializer->canHandle($objectFqcn)) {
             return $customSerializer->deserialize($curatedPayload, $objectFqcn);
         }
     }
     $object = $this->instantiator->instantiate($objectFqcn);
     return $this->hydratorFactory->getHydrator($objectFqcn)->hydrate($curatedPayload, $object);
 }
Exemplo n.º 2
0
 /**
  * @test
  */
 public function itShouldReturnAnHydratorInstance()
 {
     $hydratorFactory = new HydratorFactory(__DIR__ . DIRECTORY_SEPARATOR . 'cache', true);
     $hydrator = $hydratorFactory->getHydrator(Serializable::class);
     $this->assertInstanceOf(HydratorInterface::class, $hydrator);
 }