for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace WebPConvert\Options;
use WebPConvert\Options\Option;
use WebPConvert\Options\Exceptions\InvalidOptionValueException;
/**
* Abstract option class
*
* @package WebPConvert
* @author Bjørn Rosell <[email protected]>
* @since Class available since Release 2.0.0
*/
class IntegerOption extends Option
{
protected $minValue;
protected $maxValue;
public function __construct($id, $defaultValue, $minValue = null, $maxValue = null)
$this->minValue = $minValue;
$this->maxValue = $maxValue;
parent::__construct($id, $defaultValue);
}
protected function checkMin()
if (!is_null($this->minValue) && $this->getValue() < $this->minValue) {
throw new InvalidOptionValueException(
'"' . $this->id . '" option must be set to minimum ' . $this->minValue . '. ' .
'It was however set to: ' . $this->getValue()
);
protected function checkMax()
if (!is_null($this->maxValue) && $this->getValue() > $this->maxValue) {
'"' . $this->id . '" option must be set to max ' . $this->maxValue . '. ' .
protected function checkMinMax()
$this->checkMin();
$this->checkMax();
public function check()
$this->checkType('integer');
$this->checkMinMax();