Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
AbstractMinMaxRule | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
7 | |
100.00% |
1 / 1 |
symbol | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
comparisonString | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
7 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace WsdlToPhp\PackageGenerator\File\Validation; |
6 | |
7 | abstract class AbstractMinMaxRule extends AbstractRule |
8 | { |
9 | public const SYMBOL_MAX_INCLUSIVE = '>'; |
10 | public const SYMBOL_MAX_EXCLUSIVE = '>='; |
11 | public const SYMBOL_MIN_INCLUSIVE = '<'; |
12 | public const SYMBOL_MIN_EXCLUSIVE = '<='; |
13 | public const SYMBOL_STRICT = '!=='; |
14 | |
15 | /** |
16 | * Must return the comparison symbol. |
17 | */ |
18 | abstract public function symbol(): string; |
19 | |
20 | final public function comparisonString(): string |
21 | { |
22 | switch ($this->symbol()) { |
23 | case self::SYMBOL_MAX_INCLUSIVE: |
24 | $comparison = 'less than or equal to'; |
25 | |
26 | break; |
27 | |
28 | case self::SYMBOL_MIN_INCLUSIVE: |
29 | $comparison = 'greater than or equal to'; |
30 | |
31 | break; |
32 | |
33 | case self::SYMBOL_MIN_EXCLUSIVE: |
34 | $comparison = 'greater than'; |
35 | |
36 | break; |
37 | |
38 | case self::SYMBOL_MAX_EXCLUSIVE: |
39 | $comparison = 'less than'; |
40 | |
41 | break; |
42 | |
43 | case self::SYMBOL_STRICT: |
44 | $comparison = 'equal to'; |
45 | |
46 | break; |
47 | |
48 | default: |
49 | throw new \InvalidArgumentException(sprintf('Invalid value %s returned by symbol() method, can\'t determine comparison string', $this->symbol())); |
50 | } |
51 | |
52 | return $comparison; |
53 | } |
54 | } |