Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| Bools | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| toBoolean | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Projom\Util; |
| 6 | |
| 7 | class Bools |
| 8 | { |
| 9 | private const TRUE = 'true'; |
| 10 | private const FALSE = 'false'; |
| 11 | |
| 12 | public static function toBoolean(string $boolString): ?bool |
| 13 | { |
| 14 | $boolString = strtolower($boolString); |
| 15 | |
| 16 | if ($boolString === static::TRUE) |
| 17 | return true; |
| 18 | |
| 19 | if ($boolString === static::FALSE) |
| 20 | return false; |
| 21 | |
| 22 | return null; |
| 23 | } |
| 24 | } |