| Conditions | 7 | 
| Paths | 6 | 
| Total Lines | 29 | 
| Code Lines | 18 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 19 | 
| CRAP Score | 7 | 
| 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) > 1) { | |
| 30 | 1 | throw new TransformationException( | |
| 31 | 'Rule HtmlspecialcharsDecode expects at most 1 argument' | ||
| 32 | 1 | ); | |
| 33 | } | ||
| 34 | 4 |         if (isset($arguments[0])) { | |
| 35 | 3 | $flags_array = $arguments[0]; | |
| 36 | 3 | $arguments[0] = 0; | |
| 37 | 3 |             if (!is_array($flags_array)) { | |
| 38 | 1 | throw new TransformationException( | |
| 39 | 'First argument of HtmlspecialcharsDecode should be an array' | ||
| 40 | 1 | ); | |
| 41 | } | ||
| 42 | 2 |             foreach ($flags_array as $constant) { | |
| 43 | 2 |                 if (!defined($constant)) { | |
| 44 | 1 | throw new TransformationException( | |
| 45 | 'Flags should be valid PHP constants' | ||
| 46 | 1 | ); | |
| 47 | } | ||
| 48 | 1 | $arguments[0] |= constant($constant); | |
| 49 | 1 | } | |
| 50 | 1 |         } else { | |
| 51 | 1 |             $arguments[0] = ENT_COMPAT | (defined('ENT_HTML401') ? ENT_HTML401 : 0); | |
| 52 | } | ||
| 53 | 2 | return htmlspecialchars_decode($input, $arguments[0]); | |
| 54 | } | ||
| 55 | } | ||
| 56 |