Nelmio\Alice\Throwable\Error\TypeErrorFactory::createForInvalidParameterKey PHP Method

createForInvalidParameterKey() public static method

public static createForInvalidParameterKey ( $parameterKey ) : TypeError
return TypeError
    public static function createForInvalidParameterKey($parameterKey) : \TypeError
    {
        return new \TypeError(sprintf('Expected parameter key to be either a string or an instance of "%s". Got "%s" instead.', ValueInterface::class, is_object($parameterKey) ? get_class($parameterKey) : gettype($parameterKey)));
    }

Usage Example

Example #1
0
 /**
  * @param string|ValueInterface $parameterKey e.g. 'dummy_param'
  */
 public function __construct($parameterKey)
 {
     if (false === is_string($parameterKey) && false === $parameterKey instanceof ValueInterface) {
         throw TypeErrorFactory::createForInvalidParameterKey($parameterKey);
     }
     $this->parameterKey = $parameterKey;
 }