Assert\Assertion::max PHP Method

max() public static method

Assert that a number is smaller as a given limit
public static max ( mixed $value, mixed $maxValue, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$maxValue mixed
$message string | null
$propertyPath string | null
return boolean
    public static function max($value, $maxValue, $message = null, $propertyPath = null)
    {
        static::numeric($value, $message, $propertyPath);
        if ($value > $maxValue) {
            $message = sprintf($message ?: 'Number "%s" was expected to be at most "%s".', static::stringify($value), static::stringify($maxValue));
            throw static::createException($value, $message, static::INVALID_MAX, $propertyPath, array('max' => $maxValue));
        }
        return true;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @param string $template
  * @param string $title
  * @param int $requiredCols
  * @param null|array|\Traversable $variables
  * @param null $newGroup
  * @return DashboardWidget
  */
 public static function initialize($template, $title, $requiredCols, $variables = null, $newGroup = null)
 {
     Assertion::string($template);
     Assertion::string($title);
     Assertion::integer($requiredCols);
     Assertion::min($requiredCols, 1);
     Assertion::max($requiredCols, 12);
     $options = ['required_cols' => $requiredCols, 'title' => $title, 'new_group' => $newGroup];
     $model = new self($variables, $options);
     $model->setTemplate($template);
     return $model;
 }
All Usage Examples Of Assert\Assertion::max