| Conditions | 6 |
| Paths | 5 |
| Total Lines | 27 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 6.0493 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 26 | 5 | public function transform($input, array $arguments) |
|
| 27 | { |
||
| 28 | // I should have two arguments: old format / new format |
||
| 29 | 5 | if (count($arguments) > 3) { |
|
| 30 | 1 | throw new TransformationException( |
|
| 31 | 'Rule Htmlspecialchars expects at most 3 arguments' |
||
| 32 | 1 | ); |
|
| 33 | } |
||
| 34 | 4 | if (isset($arguments[0])) { |
|
| 35 | 2 | $flags_array = $arguments[0]; |
|
| 36 | 2 | $arguments[0] = 0; |
|
| 37 | 2 | if (!is_array($flags_array)) { |
|
| 38 | 1 | throw new TransformationException( |
|
| 39 | 'First argument of Htmlspecialchars should be an array' |
||
| 40 | 1 | ); |
|
| 41 | } |
||
| 42 | 1 | foreach ($flags_array as $constant) { |
|
| 43 | 1 | if (!defined($constant)) { |
|
| 44 | throw new TransformationException( |
||
| 45 | 'Flags should be valid PHP constants' |
||
| 46 | ); |
||
| 47 | } |
||
| 48 | 1 | $arguments[0] |= constant($constant); |
|
| 49 | 1 | } |
|
| 50 | 1 | } |
|
| 51 | 3 | return call_user_func_array('htmlspecialchars', array_merge(array($input), $arguments)); |
|
| 52 | } |
||
| 53 | } |
||
| 54 |