| Total Complexity | 6 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | final class HttpValue |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Check if the given value should be considered as empty |
||
| 12 | * Unlike php's `empty()` function, '0', false, 0, 0.0 are not considered as empty |
||
| 13 | * |
||
| 14 | * @param mixed $value Value to check |
||
| 15 | * |
||
| 16 | * @return bool true if the value is empty |
||
| 17 | */ |
||
| 18 | 34 | public static function isEmpty($value): bool |
|
| 19 | { |
||
| 20 | 34 | return $value === null || $value === '' || $value === []; |
|
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Get the http value or the default one if it's empty |
||
| 25 | * Note: If not default value is provided, the http value is returned |
||
| 26 | * |
||
| 27 | * @param mixed $value |
||
| 28 | * @param mixed $default |
||
| 29 | * |
||
| 30 | * @return mixed The value or the default |
||
| 31 | */ |
||
| 32 | 136 | public static function orDefault($value, $default) |
|
| 39 | } |
||
| 40 | } |
||
| 41 |