range() public static method

Assert that value is in range of numbers.
public static range ( mixed $value, integer $minValue, integer $maxValue, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$minValue integer
$maxValue integer
$message string | null
$propertyPath string | null
return boolean
 /**
  * Set the radius in meters.
  *
  * @param int $meters
  *
  * @return self
  */
 public function setRadius($meters)
 {
     Assertion::integer($meters);
     Assertion::range($meters, 1, 100000);
     $this->radius = $meters;
     return $this;
 }
 /**
  * Set the limit.
  *
  * @param int $limit
  *
  * @return self
  */
 public function setLimit($limit)
 {
     Assertion::integer($limit);
     Assertion::range($limit, 1, 50);
     $this->limit = $limit;
     return $this;
 }
Exemplo n.º 3
0
 /**
  * @test
  */
 public function it_passes_values_and_constraints_to_exception()
 {
     try {
         Assertion::range(0, 10, 20);
         $this->fail('Exception expected');
     } catch (AssertionFailedException $e) {
         $this->assertEquals(0, $e->getValue());
         $this->assertEquals(array('min' => 10, 'max' => 20), $e->getConstraints());
     }
 }
Exemplo n.º 4
0
 /**
  * Deflate constructor.
  *
  * @param int $compression_level
  */
 public function __construct($compression_level = -1)
 {
     Assertion::integer($compression_level, 'The compression level can be given as 0 for no compression up to 9 for maximum compression. If -1 given, the default compression level will be the default compression level of the zlib library.');
     Assertion::range($compression_level, -1, 9, 'The compression level can be given as 0 for no compression up to 9 for maximum compression. If -1 given, the default compression level will be the default compression level of the zlib library.');
     $this->compression_level = $compression_level;
 }
Exemplo n.º 5
0
 public function inRange($value, $min, $max)
 {
     parent::range($value, $min, $max);
 }
Exemplo n.º 6
0
 /**
  * @param int $status
  */
 private function setStatus($status)
 {
     Assertion::integer($status);
     Assertion::range($status, 0, 2);
     $this->status = $status;
 }
Exemplo n.º 7
0
 /**
  * @param integer $interval (1 or 2)
  *
  * @return History
  */
 public function getDataPer30Minutes($interval = 1)
 {
     Assert::range($interval, 1, 2);
     $response = $this->browser->get($this->createDataUrl(self::TYPE_HISTORICAL, array('h' => $interval)));
     return $this->processHistoricalResponse($response);
 }