for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace ValueObjects\Number;
use ValueObjects\Exception\InvalidNativeArgumentException;
class Natural extends Integer
{
/**
* 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
)
);
$filteredValue = filter_var($value, FILTER_VALIDATE_INT, $options);
if (false === $filteredValue) {
throw new InvalidNativeArgumentException($value, array('int (>=0)'));
}
parent::__construct($filteredValue);