/** * Returns a Natural object given a PHP native int as parameter. * * @param int $value */ public function __construct($value) { $options = array('options' => array('min_range' => 0)); $value = filter_var($value, FILTER_VALIDATE_INT, $options); if (false === $value) { throw new InvalidNativeArgumentException($value, array('int (>=0)')); } parent::__construct($value); }
public function __construct($value) { parent::__construct($value); try { Assertion::min($value, 0); $this->value = (int) $value; } catch (AssertionInvalidArgumentException $exception) { throw new InvalidArgumentException($value); } }