Conditions | 3 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
34 | 2 | private function transform($value, $type) |
|
35 | { |
||
36 | 2 | $type = strtolower($type); |
|
37 | 2 | $type = 'boolean' === $type ? 'bool' : $type; |
|
38 | 2 | $function = $type.'val'; |
|
39 | |||
40 | 2 | if (function_exists($function)) { |
|
41 | 1 | return $function($value); |
|
42 | } |
||
43 | |||
44 | 1 | throw new InvalidArgumentException(sprintf( |
|
45 | 1 | 'Type "%s" is invalid. There is no "%s" function. Fix your type or add that function to global namespace', |
|
46 | 1 | $type, |
|
47 | 1 | $function |
|
48 | )); |
||
51 |