Conditions | 5 |
Paths | 5 |
Total Lines | 24 |
Code Lines | 19 |
Lines | 14 |
Ratio | 58.33 % |
Changes | 0 |
1 | <?php |
||
18 | public function is_fulfilled( $environment ) { |
||
19 | $roles = $environment['roles']; |
||
20 | |||
21 | View Code Duplication | switch ( $this->get_comparison_operator() ) { |
|
1 ignored issue
–
show
|
|||
22 | case '=': |
||
23 | return in_array( $this->get_value(), $roles ); |
||
24 | break; |
||
1 ignored issue
–
show
|
|||
25 | case '!=': |
||
26 | return ! in_array( $this->get_value(), $roles ); |
||
27 | break; |
||
1 ignored issue
–
show
|
|||
28 | case 'IN': |
||
29 | return count( array_intersect( $roles, $this->get_value() ) ) > 0; |
||
30 | break; |
||
1 ignored issue
–
show
|
|||
31 | case 'NOT IN': |
||
32 | return count( array_intersect( $roles, $this->get_value() ) ) === 0; |
||
33 | break; |
||
1 ignored issue
–
show
|
|||
34 | } |
||
35 | |||
36 | return $this->first_supported_comparer_is_correct( |
||
37 | $roles, |
||
38 | $this->get_comparison_operator(), |
||
39 | $this->get_value() |
||
40 | ); |
||
41 | } |
||
42 | } |
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.