MOON
Server: Apache
System: Linux server1.studioinfinity.com.br 2.6.32-954.3.5.lve1.4.90.el6.x86_64 #1 SMP Tue Feb 21 12:26:30 UTC 2023 x86_64
User: artinside (517)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/artinside/public_html/finance/vendor/rosell-dk/webp-convert/src/Options/IntegerOption.php
<?php

namespace WebPConvert\Options;

use WebPConvert\Options\Option;
use WebPConvert\Options\Exceptions\InvalidOptionValueException;

/**
 * Abstract option class
 *
 * @package    WebPConvert
 * @author     Bjørn Rosell <it@rosell.dk>
 * @since      Class available since Release 2.0.0
 */
class IntegerOption extends Option
{

    protected $minValue;
    protected $maxValue;

    /**
     * Constructor.
     *
     * @param   string   $id              id of the option
     * @param   integer  $defaultValue    default value for the option
     * @throws  InvalidOptionValueException  if the default value cannot pass the check
     * @return  void
     */
    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) {
            throw new InvalidOptionValueException(
                '"' . $this->id . '" option must be set to max ' . $this->maxValue . '. ' .
                'It was however set to: ' . $this->getValue()
            );
        }
    }

    protected function checkMinMax()
    {
        $this->checkMin();
        $this->checkMax();
    }

    public function check()
    {
        $this->checkType('integer');
        $this->checkMinMax();
    }
}