PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.3
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.3
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / rosell-dk / webp-convert / src / Options / IntegerOrNullOption.php

IntegerOrNullOption.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.3, at vendor/rosell-dk/webp-convert/src/Options/IntegerOrNullOption.php

51 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 protected $schemaType = ['integer', 'null'];
18
19 public function __construct($id, $defaultValue, $minValue = null, $maxValue = null)
20 {
21 parent::__construct($id, $defaultValue, $minValue, $maxValue);
22 }
23
24 public function check()
25 {
26 $this->checkMinMax();
27
28 $valueType = gettype($this->getValue());
29 if (!in_array($valueType, ['integer', 'NULL'])) {
30 throw new InvalidOptionValueException(
31 'The "' . $this->id . '" option must be either integer or NULL. ' .
32 'You however provided a value of type: ' . $valueType
33 );
34 }
35 }
36
37 public function getValueForPrint()
38 {
39 if (gettype($this->getValue() == 'NULL')) {
40 return 'null (not set)';
41 }
42 return parent::getValueForPrint();
43 }
44
45 public function getDefinition()
46 {
47 $obj = parent::getDefinition();
48 return $obj;
49 }
50 }
51