Conditions | 11 |
Paths | 30 |
Total Lines | 34 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
43 | protected function iaEnabled($opts) |
||
44 | { |
||
45 | if (! $opts['enable']) { |
||
46 | return false; |
||
47 | } |
||
48 | |||
49 | if (isset($opts['offDropWith']) && ! is_null($opts['offDropWith']) && isset($_REQUEST['dropWith'])) { |
||
50 | $offDropWith = $opts['offDropWith']; |
||
51 | $action = (int) $_REQUEST['dropWith']; |
||
52 | if (! is_array($offDropWith)) { |
||
53 | $offDropWith = [$offDropWith]; |
||
54 | } |
||
55 | $res = true; |
||
56 | foreach ($offDropWith as $key) { |
||
57 | $key = (int) $key; |
||
58 | if ($key === 0) { |
||
59 | if ($action === 0) { |
||
60 | $res = false; |
||
61 | break; |
||
62 | } |
||
63 | } else { |
||
64 | if (($action & $key) === $key) { |
||
65 | $res = false; |
||
66 | break; |
||
67 | } |
||
68 | } |
||
69 | } |
||
70 | if (! $res) { |
||
71 | return false; |
||
72 | } |
||
73 | } |
||
74 | |||
75 | return true; |
||
76 | } |
||
77 | } |
||
78 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.