Nelmio\Alice\Throwable\Exception\PropertyAccess\NoSuchPropertyExceptionFactory::createForUnreadablePropertyFromStdClass PHP Method

createForUnreadablePropertyFromStdClass() public static method

public static createForUnreadablePropertyFromStdClass ( string $propertyPath ) : Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
$propertyPath string
return Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
    public static function createForUnreadablePropertyFromStdClass(string $propertyPath) : NoSuchPropertyException
    {
        return new NoSuchPropertyException(sprintf('Cannot read property "%s" from stdClass.', $propertyPath));
    }

Usage Example

Beispiel #1
0
 /**
  * @inheritdoc
  */
 public function getValue($objectOrArray, $propertyPath)
 {
     if (false === $objectOrArray instanceof \stdClass) {
         return $this->decoratedPropertyAccessor->getValue($objectOrArray, $propertyPath);
     }
     if (false === isset($objectOrArray->{$propertyPath})) {
         throw NoSuchPropertyExceptionFactory::createForUnreadablePropertyFromStdClass($propertyPath);
     }
     return $objectOrArray->{$propertyPath};
 }
NoSuchPropertyExceptionFactory