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

createForDynamicArrayQuantifier() public static method

public static createForDynamicArrayQuantifier ( $quantifier ) : TypeError
return TypeError
    public static function createForDynamicArrayQuantifier($quantifier) : \TypeError
    {
        return new \TypeError(sprintf('Expected quantifier to be either an integer or a "%s" object. Got "%s" instead.', ValueInterface::class, is_object($quantifier) ? get_class($quantifier) : gettype($quantifier)));
    }

Usage Example

Example #1
0
 /**
  * @param int|ValueInterface    $quantifier
  * @param string|ValueInterface $element
  */
 public function __construct($quantifier, $element)
 {
     if ($quantifier instanceof ValueInterface) {
         $quantifier = clone $quantifier;
     } elseif (false === is_int($quantifier)) {
         throw TypeErrorFactory::createForDynamicArrayQuantifier($quantifier);
     }
     if (false === is_string($element) && false === is_array($element) && false === $element instanceof ValueInterface) {
         throw TypeErrorFactory::createForDynamicArrayElement($element);
     }
     $this->quantifier = $quantifier;
     $this->element = deep_clone($element);
 }