/**
  * @expectedException \Opensoft\SimpleSerializer\Exception\InvalidArgumentException
  */
 public function testClassFullName()
 {
     $object = new AChildren();
     $className = ObjectHelper::getFullClassName($object);
     $this->assertEquals('Opensoft\\SimpleSerializer\\Tests\\Metadata\\Driver\\Fixture\\A\\AChildren', $className);
     ObjectHelper::getFullClassName('notClass');
 }
 /**
  * @dataProvider childrenDataProvider
  * @param AChildren $aChildren
  * @param array $aChildrenAsArray
  */
 public function testDenormalize($aChildren, $aChildrenAsArray)
 {
     $object = new E();
     $className = ObjectHelper::getFullClassName($object);
     $metadata = $this->metadataFactory->getMetadataForClass($className);
     $properties = $metadata->getProperties();
     $denormalizedObject = $this->arrayTransformer->denormalize(array($aChildrenAsArray), $properties['arrayOfObjects'], $object);
     $this->assertEquals(array($aChildren), $denormalizedObject);
 }
 /**
  * @param array $value
  * @param PropertyMetadata $property
  * @param mixed $object
  * @return array
  */
 public function denormalize($value, $property, $object)
 {
     $result = array();
     $itemProperty = $this->makeItemProperty($property);
     $existsData = ObjectHelper::expose($object, $property);
     $inner = false;
     foreach ($value as $subKey => $subValue) {
         $tmpObject = $object;
         if (isset($existsData[$subKey]) && is_object($existsData[$subKey])) {
             $tmpObject = $existsData[$subKey];
             $inner = true;
         }
         $result[$subKey] = $this->processor->denormalizeProcess($this->normalizer, $subValue, $itemProperty, $tmpObject, $inner);
         unset($tmpObject);
     }
     return $result;
 }
 /**
  * @param ArrayNormalizer $normalizer
  * @param mixed $value
  * @param PropertyMetadata $property
  * @param mixed $object
  * @param bool $inner
  * @return array|bool|DateTime|float|int|null|string
  * @throws InvalidArgumentException
  */
 public function denormalizeProcess(ArrayNormalizer $normalizer, $value, $property, $object, $inner = false)
 {
     if ($value === null) {
         return null;
     }
     $transformerAliases = array(TransformerFactory::TYPE_SIMPLE_TRANSFORMER, TransformerFactory::TYPE_DATETIME_TRANSFORMER, TransformerFactory::TYPE_ARRAY_TRANSFORMER, TransformerFactory::TYPE_OBJECT_TRANSFORMER);
     $supports = false;
     foreach ($transformerAliases as $transformerAlias) {
         $transformer = $this->transformerFactory->getTransformer($transformerAlias, $normalizer, $this);
         if ($transformer->supportType($property->getType()) && $transformer->supportValueForDenormalization($value)) {
             if ($transformerAlias === TransformerFactory::TYPE_OBJECT_TRANSFORMER && !$inner) {
                 $object = ObjectHelper::expose($object, $property);
             }
             $value = $transformer->denormalize($value, $property, $object);
             $supports = true;
             break;
         }
     }
     if (!$supports && $property->getType() !== null) {
         throw new InvalidArgumentException(sprintf('Unsupported type: %s', $property->getType()));
     }
     return $value;
 }
 /**
  * {@inheritDoc}
  *
  * @param mixed $data
  * @param object $object
  *
  * @return object
  */
 public function denormalize(array $data, $object)
 {
     $className = ObjectHelper::getFullClassName($object);
     $metadata = $this->metadataFactory->getMetadataForClass($className);
     $unserializedProperties = 0;
     foreach ($metadata->getProperties() as $property) {
         if ($this->propertySkipper->shouldSkip($property)) {
             if ($this->isMediumStrictUnserializeMode() && array_key_exists($property->getSerializedName(), $data)) {
                 throw new InvalidArgumentException(sprintf('%s extra field', $property->getSerializedName()));
             }
             continue;
         }
         if (!array_key_exists($property->getSerializedName(), $data)) {
             if ($this->isStrictUnserializeMode()) {
                 throw new InvalidArgumentException(sprintf('%s field is lost', $property->getSerializedName()));
             }
             continue;
         }
         $value = $this->dataProcessor->denormalizeProcess($this, $data[$property->getSerializedName()], $property, $object);
         ObjectHelper::involve($object, $property, $value);
         $unserializedProperties++;
     }
     if ($this->isMediumStrictUnserializeMode() && $unserializedProperties !== count($data)) {
         throw new InvalidArgumentException('Wrong number of fields in the deserialized data');
     }
     return $object;
 }