public function __construct($min = null, $max = null, $inclusive = true) { $this->minValue = $min; $this->maxValue = $max; $this->inclusive = $inclusive; $paramValidator = new OneOf(new Numeric(), new NullType()); if (!$paramValidator->validate($min)) { throw new ComponentException(sprintf('%s is not a valid numeric length', $min)); } if (!$paramValidator->validate($max)) { throw new ComponentException(sprintf('%s is not a valid numeric length', $max)); } if (!is_null($min) && !is_null($max) && $min > $max) { throw new ComponentException(sprintf('%s cannot be less than %s for validation', $min, $max)); } }
/** * Validate filters or throws an exception. * * @param array $filters List of filters * @param Rules\AllOf|Rules\OneOf $callable Validation rules * @param string $exceptionMessage Exception message * * @throws \ComicAPI\Exceptions\ComicApiException */ protected function validateFilters($filters, $callable, $exceptionMessage = "Invalid list of filters.") { if ($callable->validate($filters) === false) { throw new ComicApiException($exceptionMessage); } }