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
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;
 }
Exemplo n.º 2
0
 public function testMax()
 {
     Assertion::max(1, 1);
     Assertion::max(0.5, 1);
     Assertion::max(0, 1);
     $this->setExpectedException('Assert\\AssertionFailedException', null, Assertion::INVALID_MAX);
     Assertion::max(2, 1);
 }
Exemplo n.º 3
0
 /**
  * Validate quantity in stock:
  * 0 <= $quantityInStock <= 500
  * @param int $quantityInStock
  */
 public static function quantityInStock($quantityInStock)
 {
     Assert::min($quantityInStock, 0);
     Assert::max($quantityInStock, 500);
 }
Exemplo n.º 4
0
 /**
  * @param int $retryCount
  */
 private function setRetryCount($retryCount)
 {
     Assertion::integer($retryCount);
     Assertion::min($retryCount, 0);
     Assertion::max($retryCount, $this->retryLimit);
     $this->retryCount = $retryCount;
 }