Conditions | 12 |
Paths | 132 |
Total Lines | 38 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
22 | public function listInstances($includeFilter = [], $excludeFilter = []) |
||
23 | { |
||
24 | if (!is_array($includeFilter)) { |
||
25 | $includeFilter = [$includeFilter]; |
||
26 | } |
||
27 | if (!is_array($excludeFilter)) { |
||
28 | $excludeFilter = [$excludeFilter]; |
||
29 | } |
||
30 | |||
31 | $names = []; |
||
32 | foreach(array_keys($this->instanceList) as $name) { |
||
33 | |||
34 | if (empty($includeFilter)) { |
||
35 | $include = true; |
||
36 | } else { |
||
37 | $include = false; |
||
38 | foreach($includeFilter as $filter) { |
||
39 | if (fnmatch($filter, $name)) { |
||
40 | $include = true; |
||
41 | break; |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 | |||
46 | if ($include && !empty($excludeFilter)) { |
||
47 | foreach($excludeFilter as $filter) { |
||
48 | if (fnmatch($filter, $name)) { |
||
49 | $include = false; |
||
50 | break; |
||
51 | } |
||
52 | } |
||
53 | } |
||
54 | |||
55 | if ($include) { |
||
56 | $names[] = $name; |
||
57 | } |
||
58 | } |
||
59 | return $names; |
||
60 | } |
||
91 |