1 | <?php |
||
11 | final class Booleans |
||
12 | { |
||
13 | /** |
||
14 | * Filters $value to a boolean strictly. |
||
15 | * |
||
16 | * $value must be a bool or 'true' or 'false' disregarding case and whitespace. |
||
17 | * |
||
18 | * The return value is the bool, as expected by the \DominionEnterprises\Filterer class. |
||
19 | * |
||
20 | * @param string|bool $value the value to filter to a boolean |
||
21 | * @param bool $allowNull Set to true if NULL values are allowed. The filtered result of a NULL value is NULL |
||
22 | * @param array $trueValues Array of values which represent the boolean true value. Values should be lowercased |
||
23 | * @param array $falseValues Array of values which represent the boolean false value. Values should be lowercased |
||
24 | * |
||
25 | * @return bool|null the filtered $value |
||
26 | * |
||
27 | * @throws \InvalidArgumentException if $allowNull is not a boolean |
||
28 | * @throws \Exception if $value is not a string |
||
29 | * @throws \Exception if $value is not 'true' or 'false' disregarding case and whitespace |
||
30 | */ |
||
31 | public static function filter( |
||
73 | |||
74 | /** |
||
75 | * Filters the boolean $value to the given $true and $false cases |
||
76 | * |
||
77 | * @param boolean $value The boolean value to convert. |
||
78 | * @param mixed $true The value to return on the true case. |
||
79 | * @param mixed $false The value to return on the false case. |
||
80 | * |
||
81 | * @return mixed |
||
82 | * |
||
83 | * @throws \Exception Thrown if $value is not a boolean |
||
84 | */ |
||
85 | public static function convert($value, $true = 'true', $false = 'false') |
||
93 | } |
||
94 |