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