# wp-optimize/3.2.3/vendor/rosell-dk/webp-convert/src/Options/IntegerOrNullOption.php

WP-Optimize – Cache, Compress images, Minify &amp; Clean database to boost page speed &amp; performance, version 3.2.3. 51 lines.

- Page: https://pluginprobe.com/plugins/wp-optimize/3.2.3/code/vendor/rosell-dk/webp-convert/src/Options/IntegerOrNullOption.php
- Raw: https://pluginprobe.com/plugins/wp-optimize/3.2.3/raw/vendor/rosell-dk/webp-convert/src/Options/IntegerOrNullOption.php
- Modified: 2021-11-30T14:57:30+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-optimize/3.2.3/code/vendor/rosell-dk/webp-convert/src/Options/IntegerOrNullOption.php#L10-L20`.

```php
<?php

namespace WebPConvert\Options;

use WebPConvert\Options\IntegerOption;
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 IntegerOrNullOption extends IntegerOption
{
    protected $schemaType = ['integer', 'null'];

    public function __construct($id, $defaultValue, $minValue = null, $maxValue = null)
    {
        parent::__construct($id, $defaultValue, $minValue, $maxValue);
    }

    public function check()
    {
        $this->checkMinMax();

        $valueType = gettype($this->getValue());
        if (!in_array($valueType, ['integer', 'NULL'])) {
            throw new InvalidOptionValueException(
                'The "' . $this->id . '" option must be either integer or NULL. ' .
                    'You however provided a value of type: ' . $valueType
            );
        }
    }

    public function getValueForPrint()
    {
        if (gettype($this->getValue() == 'NULL')) {
            return 'null (not set)';
        }
        return parent::getValueForPrint();
    }

    public function getDefinition()
    {
        $obj = parent::getDefinition();
        return $obj;
    }
}

```
