Nelmio\Alice\Throwable\Exception\Generator\Hydrator\HydrationExceptionFactory::create PHP Method

create() public static method

public static create ( Nelmio\Alice\ObjectInterface $object, Property $property, integer $code, Throwable $previous ) : HydrationException
$object Nelmio\Alice\ObjectInterface
$property Nelmio\Alice\Definition\Property
$code integer
$previous Throwable
return HydrationException
    public static function create(ObjectInterface $object, Property $property, int $code, \Throwable $previous) : HydrationException
    {
        return new HydrationException(sprintf('Could not hydrate the property "%s" of the object "%s" (class: %s).', $property->getName(), $object->getId(), get_class($object->getInstance())), $code, $previous);
    }

Usage Example

 public function testTestCreate()
 {
     $object = new SimpleObject('dummy', new \stdClass());
     $property = new Property('foo', 'bar');
     $code = 500;
     $previous = new \Error();
     $exception = HydrationExceptionFactory::create($object, $property, $code, $previous);
     $this->assertEquals('Could not hydrate the property "foo" of the object "dummy" (class: stdClass).', $exception->getMessage());
     $this->assertEquals($code, $exception->getCode());
     $this->assertSame($previous, $exception->getPrevious());
 }
All Usage Examples Of Nelmio\Alice\Throwable\Exception\Generator\Hydrator\HydrationExceptionFactory::create