Total Complexity | 5 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | class Invalid { |
||
18 | private static $value; |
||
19 | |||
20 | /** |
||
21 | * Private constructor to enforce singleton. |
||
22 | * |
||
23 | * @noinspection PhpUnusedPrivateMethodInspection |
||
24 | */ |
||
25 | 1 | private function __construct() { |
|
26 | // no-op |
||
27 | 1 | } |
|
28 | |||
29 | /** |
||
30 | * Return the invalid value. |
||
31 | * |
||
32 | * @return Invalid Returns the invalid value. |
||
33 | */ |
||
34 | 234 | public static function value() { |
|
35 | 234 | if (self::$value === null) { |
|
36 | 1 | self::$value = new Invalid(); |
|
37 | } |
||
38 | 234 | return self::$value; |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * Tests a value to see if it is invalid. |
||
43 | * |
||
44 | * @param mixed $value The value to test. |
||
45 | * @return bool Returns **true** of the value is invalid or **false** otherwise. |
||
46 | */ |
||
47 | 232 | public static function isInvalid($value) { |
|
48 | 232 | return $value === self::value(); |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * Tests whether a value could be valid. |
||
53 | * |
||
54 | * Unlike {@link Invalid::inValid()} a value could still be invalid in some way even if this method returns true. |
||
55 | * |
||
56 | * @param mixed $value The value to test. |
||
57 | * @return bool Returns **true** of the value could be invalid or **false** otherwise. |
||
58 | */ |
||
59 | 231 | public static function isValid($value) { |
|
61 | } |
||
62 | } |
||
63 |