Conditions | 6 |
Paths | 6 |
Total Lines | 20 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
45 | public function checkValue($attribute) |
||
46 | { |
||
47 | // Catch if value null |
||
48 | if (is_null($attribute)) { |
||
49 | return 'F'; |
||
50 | } |
||
51 | |||
52 | if (is_string($attribute)) { |
||
53 | $attribute = trim($attribute); // remove whitespace |
||
54 | |||
55 | // Catch lowercase 't' or 'f' |
||
56 | // Catch whole words 'True' or 'False' |
||
57 | $firstChar = substr($attribute, 0, 1); |
||
58 | if ($firstChar === 't' || $firstChar === 'f') { |
||
59 | return strtoupper($firstChar); |
||
60 | } |
||
61 | } |
||
62 | |||
63 | // Not 'T' or 'F' OR not string - boolean filter validation |
||
64 | return filter_var($attribute, FILTER_VALIDATE_BOOLEAN) ? 'T' : 'F'; |
||
65 | } |
||
67 |