Conditions | 9 |
Paths | 8 |
Total Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 9.1918 |
Changes | 0 |
1 | <?php |
||
20 | 4 | public function applyToNode(Node $node) |
|
21 | { |
||
22 | 4 | $instruction = $node->getInstruction($this); |
|
23 | |||
24 | 4 | if (is_array($instruction) || is_object($instruction)) { |
|
25 | 4 | $instruction = (object)$instruction; |
|
26 | 4 | } |
|
27 | |||
28 | 4 | if (!isset($instruction) || !isset($instruction->input) || !isset($instruction->replacement)) { |
|
29 | return; |
||
30 | } |
||
31 | |||
32 | 4 | if (!isset($instruction->find) && !isset($instruction->regex)) { |
|
33 | return; |
||
34 | } |
||
35 | |||
36 | 4 | if (isset($instruction->find)) { |
|
37 | 2 | $result = str_replace($instruction->find, $instruction->replacement, $instruction->input); |
|
38 | 2 | } else { |
|
39 | 2 | $result = preg_replace($instruction->regex, $instruction->replacement, $instruction->input); |
|
40 | } |
||
41 | |||
42 | 4 | $node->setResult($result); |
|
43 | 4 | } |
|
44 | } |
||
45 |