| Total Complexity | 10 |
| Total Lines | 62 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | class AbstractBooleanCase |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Pseudo-true representations. |
||
| 9 | * |
||
| 10 | * @var array |
||
| 11 | */ |
||
| 12 | protected $true = array('1', 'on', 'true', 't', 'yes', 'y'); |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Pseudo-false representations; `null` and empty-string are *not* included. |
||
| 16 | * |
||
| 17 | * @var array |
||
| 18 | */ |
||
| 19 | protected $false = array('0', 'off', 'false', 'f', 'no', 'n'); |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Is a value true-ish? |
||
| 23 | * |
||
| 24 | * @param mixed $value The value to check. |
||
| 25 | * |
||
| 26 | * @return bool |
||
| 27 | */ |
||
| 28 | 225 | protected function isTrue($value) |
|
| 29 | { |
||
| 30 | 225 | if (!$this->isBoolIsh($value)) { |
|
| 31 | 6 | return false; |
|
| 32 | } |
||
| 33 | |||
| 34 | 219 | return $value === true || in_array(strtolower(trim($value)), $this->true); |
|
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Is a value false-ish? |
||
| 39 | * |
||
| 40 | * @param mixed $value The value to check. |
||
| 41 | * |
||
| 42 | * @return bool |
||
| 43 | */ |
||
| 44 | 117 | protected function isFalse($value) |
|
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Can the value be checked for true/false-ish-ness? |
||
| 55 | * |
||
| 56 | * @param mixed $value The value to check. |
||
| 57 | * |
||
| 58 | * @return bool |
||
| 59 | */ |
||
| 60 | 225 | protected function isBoolIsh($value) |
|
| 69 |