Conditions | 7 |
Paths | 7 |
Total Lines | 23 |
Code Lines | 17 |
Lines | 8 |
Ratio | 34.78 % |
Tests | 0 |
CRAP Score | 56 |
Changes | 0 |
1 | <?php |
||
24 | public function is_correct( $a, $comparison_operator, $b ) { |
||
25 | View Code Duplication | if ( ! is_scalar( $a ) ) { |
|
1 ignored issue
–
show
|
|||
26 | Incorrect_Syntax_Exception::raise( 'Environment value for comparison is not scalar: ' . print_r( $a, true ) ); |
||
27 | return false; |
||
28 | } |
||
29 | |||
30 | View Code Duplication | if ( ! is_scalar( $b ) ) { |
|
1 ignored issue
–
show
|
|||
31 | Incorrect_Syntax_Exception::raise( 'Supplied comparison value is not scalar: ' . print_r( $b, true ) ); |
||
32 | return false; |
||
33 | } |
||
34 | |||
35 | switch ( $comparison_operator ) { |
||
36 | case '>': |
||
37 | return $a > $b; |
||
38 | case '>=': |
||
39 | return $a >= $b; |
||
40 | case '<': |
||
41 | return $a < $b; |
||
42 | case '<=': |
||
43 | return $a <= $b; |
||
44 | } |
||
45 | return false; |
||
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.