Conditions | 14 |
Paths | 9 |
Total Lines | 43 |
Code Lines | 25 |
Lines | 0 |
Ratio | 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 |
||
33 | public function src($accept, $exclude = null) : self |
||
34 | { |
||
35 | if ((!is_string($accept) && !is_array($accept)) || ($exclude !== null && !is_string($exclude) && !is_array($exclude))) { |
||
36 | throw new \InvalidArgumentException('You can only pass a string pattern or array with patterns'); |
||
37 | } |
||
38 | |||
39 | if (is_array($accept)) { |
||
40 | $fileGroups = []; |
||
41 | |||
42 | foreach ($accept as $pattern) { |
||
43 | $fileGroups[] = $this->recoursiveGlob($pattern, GLOB_ERR); |
||
44 | } |
||
45 | |||
46 | $this->globs = call_user_func_array('array_merge', $fileGroups); |
||
|
|||
47 | } else { |
||
48 | $this->globs = $this->recoursiveGlob($accept, GLOB_ERR); |
||
49 | } |
||
50 | |||
51 | if ($exclude !== null) { |
||
52 | $cbFilter = function () {return true;}; |
||
53 | |||
54 | if (is_array($exclude) && count($exclude) > 0) { |
||
55 | $cbFilter = function ($glob) use ($exclude) { |
||
56 | foreach ($exclude as $pattern) { |
||
57 | if (preg_match($pattern, $glob)) { |
||
58 | return false; |
||
59 | } |
||
60 | } |
||
61 | |||
62 | return true; |
||
63 | };echo 'a'; |
||
64 | } elseif (is_string($exclude)) { |
||
65 | echo 'a'; |
||
66 | $cbFilter = function ($glob) use ($exclude) { |
||
67 | return !preg_match($exclude, $glob); |
||
68 | }; |
||
69 | } |
||
70 | |||
71 | $this->globs = array_filter($this->globs, $cbFilter); |
||
72 | } |
||
73 | |||
74 | return $this; |
||
75 | } |
||
76 | |||
224 | } |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..