getValue() public method

public getValue ( ) : Nelmio\Alice\Definition\ValueInterface | mixed
return Nelmio\Alice\Definition\ValueInterface | mixed
Ejemplo n.º 1
0
 public function testIsMutable()
 {
     $value = new \stdClass();
     $definition = new Property('username', $value);
     // Mutate injected value
     $value->foo = 'bar';
     // Mutate returned value
     $definition->getValue()->ping = 'pong';
     $expected = StdClassFactory::create(['foo' => 'bar', 'ping' => 'pong']);
     $actual = $definition->getValue();
     $this->assertEquals($expected, $actual);
 }
 /**
  * {@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);
 }