Conditions | 4 |
Paths | 2 |
Total Lines | 20 |
Code Lines | 11 |
Lines | 14 |
Ratio | 70 % |
Tests | 11 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
26 | 8 | public function compile($negate = false) { |
|
27 | 8 | $left_condition = $this->left()->compile($negate); |
|
28 | 8 | $right_condition = $this->right()->compile($negate); |
|
29 | |||
30 | // normal case: left_condition and not right_condition |
||
31 | 8 | View Code Duplication | if (!$negate) { |
|
|||
32 | return function(Node $n) use ($left_condition, $right_condition) { |
||
33 | 7 | return $left_condition($n) |
|
34 | 7 | && !$right_condition($n); |
|
35 | 7 | }; |
|
36 | } |
||
37 | // negated case: not (left_condition and not right_condition) |
||
38 | // = not left_condition or right_condition |
||
39 | else { |
||
40 | 1 | return function(Node $n) use ($left_condition, $right_condition) { |
|
41 | 1 | return $left_condition($n) |
|
42 | 1 | || !$right_condition($n); |
|
43 | 1 | }; |
|
44 | } |
||
45 | } |
||
46 | } |
||
47 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.