| Conditions | 2 |
| Paths | 2 |
| Total Lines | 28 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | public function transform($str, array $mapping = null) |
||
| 15 | { |
||
| 16 | $str = strtolower($str); |
||
| 17 | |||
| 18 | $formats = [ |
||
| 19 | 'active' => true, |
||
| 20 | 'activated' => true, |
||
| 21 | 'enabled' => true, |
||
| 22 | 'disabled' => false, |
||
| 23 | 'true' => true, |
||
| 24 | 'false' => false, |
||
| 25 | 'yes' => true, |
||
| 26 | 'no' => false, |
||
| 27 | '1' => true, |
||
| 28 | '0' => false, |
||
| 29 | ]; |
||
| 30 | |||
| 31 | if (false === array_key_exists($str, $formats)) { |
||
| 32 | throw new \Exception( |
||
| 33 | sprintf( |
||
| 34 | '"%s" is not a supported format. Supported format : [%s].', |
||
| 35 | $str, |
||
| 36 | implode(', ', array_keys($formats)) |
||
| 37 | ) |
||
| 38 | ); |
||
| 39 | } |
||
| 40 | |||
| 41 | return $formats[$str]; |
||
| 42 | } |
||
| 54 |