Conditions | 22 |
Paths | 181 |
Total Lines | 60 |
Code Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
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 |
||
33 | public function getPatternResolve() |
||
34 | { |
||
35 | $routes = $this->route->getRoutes(); |
||
|
|||
36 | |||
37 | if(!isset($routes['pattern'])){ |
||
38 | return []; |
||
39 | } |
||
40 | |||
41 | $patterns = $routes['pattern']; |
||
42 | $urlRoute = array_filter(route(),'strlen'); |
||
43 | |||
44 | $patternList = []; |
||
45 | |||
46 | foreach($routes['data'] as $patternKey=>$routeData){ |
||
47 | if($routeData['http']==httpMethod()){ |
||
48 | $patternList[$patternKey]=$patterns[$patternKey]; |
||
49 | } |
||
50 | } |
||
51 | |||
52 | $scoredList = []; |
||
53 | |||
54 | foreach ($patternList as $key=>$pattern){ |
||
55 | |||
56 | $patternCount = $this->getPatternRealCount($pattern); |
||
57 | |||
58 | if(count($urlRoute)==0 && count($urlRoute)==0) return array_key_first($patternList); |
||
59 | |||
60 | if(isset($patternCount['optional'])){ |
||
61 | $optionalCount = count($patternCount['default']) + count($patternCount['optional']); |
||
62 | } |
||
63 | |||
64 | if(count($urlRoute) == count($patternCount['default']) || |
||
65 | (isset($optionalCount) && count($urlRoute)>count($patternCount['default']) && $optionalCount>=count($urlRoute)) |
||
66 | ){ |
||
67 | |||
68 | foreach ($pattern as $pkey=>$item){ |
||
69 | |||
70 | if($this->route->isMatchVaribleRegexPattern($item)===false){ |
||
71 | if(isset($urlRoute[$pkey]) && $urlRoute[$pkey]==$item){ |
||
72 | $scoredList[$key][] = 3; |
||
73 | } |
||
74 | } |
||
75 | |||
76 | if($this->route->isMatchVaribleRegexPattern($item) && !$this->route->isOptionalVaribleRegexPattern($item)){ |
||
77 | if(isset($urlRoute[$pkey])){ |
||
78 | $scoredList[$key][] = 2; |
||
79 | } |
||
80 | } |
||
81 | |||
82 | if($this->route->isMatchVaribleRegexPattern($item) && $this->route->isOptionalVaribleRegexPattern($item)){ |
||
83 | if(isset($urlRoute[$pkey])){ |
||
84 | $scoredList[$key][] = 1; |
||
85 | } |
||
86 | } |
||
87 | } |
||
88 | } |
||
89 | |||
90 | } |
||
91 | |||
92 | return $this->showKeyAccordingToScoredList($scoredList); |
||
93 | |||
168 | } |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.