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