/**
  * Build value.
  *
  * @param ReflectionParameter $parameter
  * @param ParameterBag        $data
  *
  * @return array|mixed|null
  */
 protected static function buildValue(ReflectionParameter $parameter, ParameterBag $data)
 {
     $class = $parameter->getClass();
     $name = $parameter->getName();
     $value = $data->get($name);
     if (null === $class) {
         return self::castType($value, $value, '');
     }
     $value = array_merge($data->all(), (array) $value);
     return self::buildObjectParameter($class, $value, $name);
 }
 /**
  * {@inheritdoc}
  */
 public static function deserialize(array $parameter)
 {
     $parameter = new ParameterBag($parameter);
     $reflection = new ReflectionClass(get_called_class());
     $aggregate = new static();
     foreach ($parameter->all() as $index => $value) {
         if ($reflection->hasProperty($index)) {
             $reflection->getProperty($index)->setAccessible(true);
             $reflection->getProperty($index)->setValue($aggregate, $value);
         }
     }
     return $aggregate;
 }