Exemplo n.º 1
0
 public function testIsPositiveInteger()
 {
     $num = new Numeric();
     $var = 11;
     $res = $num->isPositiveInteger($var);
     $this->assertEquals(true, $res);
     $var2 = 11.35;
     $res2 = $num->isPositiveInteger($var2);
     $this->assertEquals(false, $res2);
     $var = -11;
     $res = $num->isPositiveInteger($var);
     $this->assertEquals(false, $res);
 }
Exemplo n.º 2
0
 /**
  * Update a sequence to $value only if greater than its current value.
  *
  * @param string $name
  * @param int    $value
  *
  * @return int
  *
  * @throws InvalidArgumentException Occures if $value is not a positive integer
  */
 public function increaseTo($name, $value)
 {
     if (false === Numeric::isPositiveInteger($value, false)) {
         throw new InvalidArgumentException('Value of a sequence must be a positive integer');
     }
     $current = $this->read($name);
     if ($value > $current) {
         return $this->update($name, $value);
     }
     return $current;
 }
Exemplo n.º 3
0
 /**
  * Sets the position.
  * @param  integer              $position
  *
  * @return Page
  *
  * @throws InvalidArgumentException                 Raises if the value can not be cast to positive integer.
  */
 public function setPosition($position)
 {
     if (false === Numeric::isPositiveInteger($position, false)) {
         throw new InvalidArgumentException('A position must be a positive integer.');
     }
     $this->_position = $position;
     return $this;
 }
Exemplo n.º 4
0
 /**
  * Sets the level.
  *
  * @param  type                                        $level
  * @return \BackBee\NestedNode\AbstractNestedNode
  * @throws \BackBee\Exception\InvalidArgumentException Occurs if the value can not be cast to positive integer
  */
 public function setLevel($level)
 {
     if (false === Numeric::isPositiveInteger($level, false)) {
         throw new InvalidArgumentException('A nested level must be a positive integer.');
     }
     $this->_level = $level;
     return $this;
 }
Exemplo n.º 5
0
 /**
  * Returns the zone at the index $index.
  *
  * @param int $index
  *
  * @return \StdClass|null
  *
  * @throws InvalidArgumentException
  */
 public function getZone($index)
 {
     if (false === Numeric::isPositiveInteger($index, false)) {
         throw new InvalidArgumentException('Invalid integer value.');
     }
     if (null !== ($zones = $this->getZones())) {
         if ($index < count($zones)) {
             return $zones[$index];
         }
     }
     return;
 }