eZ\Publish\Core\Base\Exceptions\InvalidArgumentException::__construct PHP Method

__construct() public method

Generates: "Argument '{$argumentName}' is invalid: {$whatIsWrong}".
public __construct ( string $argumentName, string $whatIsWrong, Exception $previous = null )
$argumentName string
$whatIsWrong string
$previous Exception
    public function __construct($argumentName, $whatIsWrong, Exception $previous = null)
    {
        $this->setMessageTemplate("Argument '%argumentName%' is invalid: %whatIsWrong%");
        $this->setParameters(['%argumentName%' => $argumentName, '%whatIsWrong%' => $whatIsWrong]);
        parent::__construct($this->getBaseTranslation(), 0, $previous);
    }

Usage Example

 /**
  * Generates: "Argument '{$argumentName}' is invalid: expected value to be of type '{$expectedType}'[, got '{$value}']".
  *
  * @param string $argumentName
  * @param string $expectedType
  * @param mixed|null $value Optionally to output the type that was received
  * @param \Exception|null $previous
  */
 public function __construct($argumentName, $expectedType, $value = null, Exception $previous = null)
 {
     if ($value === null) {
         $valueString = '';
     } elseif (is_object($value)) {
         $valueString = ", got '" . get_class($value) . "'";
     } else {
         $valueString = ", got '" . gettype($value) . "'";
     }
     parent::__construct($argumentName, "expected value to be of type '{$expectedType}'" . $valueString, $previous);
 }
All Usage Examples Of eZ\Publish\Core\Base\Exceptions\InvalidArgumentException::__construct
InvalidArgumentException