Test Failed
Push — master ( 975525...307699 )
by Bjørn
02:39
created

IntegerOrNullOption::check()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace WebPConvert\Options;
4
5
use WebPConvert\Options\IntegerOption;
6
use WebPConvert\Options\Exceptions\InvalidOptionValueException;
7
8
/**
9
 * Abstract option class
10
 *
11
 * @package    WebPConvert
12
 * @author     Bjørn Rosell <[email protected]>
13
 * @since      Class available since Release 2.0.0
14
 */
15
class IntegerOrNullOption extends IntegerOption
16
{
17
18
    public function __construct($id, $defaultValue, $minValue = null, $maxValue = null)
19
    {
20
        parent::__construct($id, $defaultValue, $minValue, $maxValue);
21
    }
22
23
    public function check()
24
    {
25
        $this->checkMinMax();
26
27
        $valueType = gettype($this->getValue());
28
        if (!in_array($valueType, ['integer', 'NULL'])) {
29
            throw new InvalidOptionValueException(
30
                'The "' . $this->id . '" option must be either integer or NULL. ' .
31
                    'You however provided a value of type: ' . $valueType
32
            );
33
        }
34
    }
35
}
36