public function testReadAccessorsReturnPropertiesValues() { $property = 'username'; $value = new \stdClass(); $definition = new Property($property, $value); $this->assertEquals($property, $definition->getName()); $this->assertEquals($value, $definition->getValue()); }
/** * {@inheritdoc} * * @throws NoSuchPropertyException * @throws InaccessiblePropertyException * @throws InvalidArgumentException When the typehint does not match for example * @throws HydrationException */ public function hydrate(ObjectInterface $object, Property $property, GenerationContext $context) : ObjectInterface { $instance = $object->getInstance(); try { $this->propertyAccessor->setValue($instance, $property->getName(), $property->getValue()); } catch (SymfonyNoSuchPropertyException $exception) { throw HydrationExceptionFactory::createForCouldNotHydrateObjectWithProperty($object, $property, 0, $exception); } catch (SymfonyAccessException $exception) { throw HydrationExceptionFactory::createForInaccessibleProperty($object, $property, 0, $exception); } catch (SymfonyInvalidArgumentException $exception) { throw HydrationExceptionFactory::createForInvalidProperty($object, $property, 0, $exception); } catch (SymfonyPropertyAccessException $exception) { throw HydrationExceptionFactory::create($object, $property, 0, $exception); } return new SimpleObject($object->getId(), $instance); }
public static function createForCouldNotHydrateObjectWithProperty(ObjectInterface $object, Property $property, int $code = 0, \Throwable $previous = null) : NoSuchPropertyException { return new NoSuchPropertyException(sprintf('Could not hydrate the property "%s" of the object "%s" (class: %s).', $property->getName(), $object->getId(), get_class($object->getInstance())), $code, $previous); }