integerish() public static method

Assert that value is a php integer'ish.
public static integerish ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean
 /**
  * @param string $direction
  * @param int $days
  */
 public function __construct($direction, $days)
 {
     Assertion::integerish($days);
     Assertion::choice($direction, [self::DIRECTION_PAST, self::DIRECTION_FUTURE]);
     $this->direction = $direction;
     $this->days = (int) $days;
 }
Beispiel #2
0
 public function __construct($value)
 {
     try {
         Assertion::integerish($value);
         $this->value = (int) $value;
     } catch (AssertionInvalidArgumentException $exception) {
         throw new InvalidArgumentException($value, array('integer'));
     }
 }
 public function __construct($filters, $offset, $limit, $sortField, $sortOrder, $isPaginated)
 {
     Assertion::isArray($filters, "Invalid filters");
     Assertion::integerish($limit, "Invalid limit");
     Assertion::integerish($offset, "Invalid offset");
     Assertion::nullOrString($sortField, "Invalid sort field");
     Assertion::choice($sortOrder, [null, self::ORDER_ASC, self::ORDER_DESC], "Invalid sort order");
     Assertion::boolean($isPaginated, "Invalid value for isPaginated");
     if ($limit < 0) {
         throw new \InvalidArgumentException("Invalid limit");
     }
     if ($offset < 0) {
         throw new \InvalidArgumentException("Invalid offset");
     }
     $this->filters = $filters;
     $this->offset = (int) $offset;
     $this->limit = (int) $limit;
     $this->sortField = $sortField;
     $this->sortOrder = $sortOrder;
     $this->isPaginated = (bool) $isPaginated;
 }
 /**
  * @param int $days
  */
 public function __construct($days)
 {
     Assertion::integerish($days);
     $this->days = (int) $days;
 }
Beispiel #5
0
 /**
  * @dataProvider dataInvalidIntegerish
  */
 public function testInvalidIntegerish($nonInteger)
 {
     $this->setExpectedException('Assert\\AssertionFailedException', null, Assertion::INVALID_INTEGERISH);
     Assertion::integerish($nonInteger);
 }
Beispiel #6
0
 function _validateAmountIsNumeric()
 {
     Assertion::integerish($this->amount);
 }
Beispiel #7
0
 /**
  * @param int $minSales
  */
 public function __construct($minSales)
 {
     Assertion::integerish($minSales);
     $this->minSales = (int) $minSales;
 }
 /**
  * @param int $chunkSize
  * @return string
  */
 public function read($chunkSize = self::DEFAULT_CHUNK_SIZE)
 {
     Assertion::integerish($chunkSize);
     return fread($this->resource, $chunkSize);
 }