/** * {@inheritDoc} */ public function create(array $definition = null) { $identity = new $this->classFQN(); if (!empty($definition)) { $class = $this->getIdentityReflection($identity); $methods = $class->getMethods(\ReflectionMethod::IS_PUBLIC); $properties = $class->getproperties(); foreach ($methods as $method) { $annotations = $this->reader->getMethodAnnotations($method); foreach ($annotations as $annotation) { switch (true) { case $annotation instanceof Identity: if (!empty($annotation->name) && $annotation->type == 'setter' && isset($definition[$annotation->name])) { $method->invoke($identity, $definition[$annotation->name]); } break; } } } foreach ($properties as $property) { $annotations = $this->reader->getPropertyAnnotations($property); foreach ($annotations as $annotation) { switch (true) { case $annotation instanceof Identity: if (empty($annotation->name)) { $annotation->name = $property->getName(); } if (isset($definition[$annotation->name])) { $this->accessor->setValue($identity, $property->getName(), $definition[$annotation->name]); } break; } } } } return $identity; }