Nelmio\Alice\Throwable\Exception\Generator\Hydrator\HydrationExceptionFactory::createForInvalidProperty PHP Метод

createForInvalidProperty() публичный статический Метод

public static createForInvalidProperty ( Nelmio\Alice\ObjectInterface $object, Property $property, integer $code, Throwable $previous = null ) : InvalidArgumentException
$object Nelmio\Alice\ObjectInterface
$property Nelmio\Alice\Definition\Property
$code integer
$previous Throwable
Результат InvalidArgumentException
    public static function createForInvalidProperty(ObjectInterface $object, Property $property, int $code = 0, \Throwable $previous = null) : InvalidArgumentException
    {
        return new InvalidArgumentException(sprintf('Invalid value given for the property "%s" of the object "%s" (class: %s).', $property->getName(), $object->getId(), get_class($object->getInstance())), $code, $previous);
    }

Usage Example

 public function testTestCreateForInvalidProperty()
 {
     $object = new SimpleObject('dummy', new \stdClass());
     $property = new Property('foo', 'bar');
     $exception = HydrationExceptionFactory::createForInvalidProperty($object, $property);
     $this->assertEquals('Invalid value given for the property "foo" of the object "dummy" (class: stdClass).', $exception->getMessage());
     $this->assertEquals(0, $exception->getCode());
     $this->assertNull($exception->getPrevious());
     $code = 500;
     $previous = new \Error();
     $exception = HydrationExceptionFactory::createForInvalidProperty($object, $property, $code, $previous);
     $this->assertEquals('Invalid value given for 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::createForInvalidProperty