Example #1
0
 /**
  * Create array from object
  *
  * @param object $object
  *
  * @return mixed[]
  */
 private function setArray($object) : array
 {
     $data = [];
     $configurationObject = $this->configuration->getConfigurationObjectForClass(new ClassName(get_class($object)));
     $identifier = $configurationObject->getIdentifier();
     if ($identifier !== '') {
         $data[$this->configuration->getIdentifierAttribute()] = $identifier;
     }
     foreach ($configurationObject->getAttributes() as $attribute) {
         $type = $configurationObject->getTypeForAttribute($attribute);
         $data = $this->processSerializeForType($type, $object, $data, $attribute);
     }
     return $data;
 }
Example #2
0
 /**
  * Create $className object with data
  *
  * @param ClassName $className
  * @param mixed[] $data
  *
  * @return object|object[]
  */
 private function setObjectForClass(ClassName $className, array $data)
 {
     $fqdnClass = $className->getValue();
     $object = new $fqdnClass();
     foreach ($data as $attribute => $value) {
         $configurationObject = $this->configuration->getConfigurationObjectForClass($className);
         $type = $configurationObject->getTypeForAttribute($attribute);
         $this->processDeserializeForType($type, $object, $value);
     }
     return $object;
 }