Conditions | 13 |
Paths | 28 |
Total Lines | 52 |
Code Lines | 27 |
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 |
||
38 | public function getPatternResolve() |
||
39 | { |
||
40 | $routes = $this->route->getRoutes(); |
||
|
|||
41 | |||
42 | if(!isset($routes['pattern'])){ |
||
43 | return []; |
||
44 | } |
||
45 | |||
46 | $patterns = $routes['pattern']; |
||
47 | $urlRoute = array_filter(route(),'strlen'); |
||
48 | |||
49 | $patternList = []; |
||
50 | |||
51 | foreach($routes['data'] as $patternKey=>$routeData){ |
||
52 | if($routeData['http']==httpMethod()){ |
||
53 | $patternList[$patternKey]=$patterns[$patternKey]; |
||
54 | } |
||
55 | } |
||
56 | |||
57 | $patternList = $this->matchingUrlMethod($patternList,$urlRoute); |
||
58 | |||
59 | foreach ($patternList as $key=>$pattern){ |
||
60 | |||
61 | $pattern = array_filter($pattern,'strlen'); |
||
62 | $diff = Arr::arrayDiffKey($pattern,$urlRoute); |
||
63 | |||
64 | if($diff){ |
||
65 | |||
66 | $matches = true; |
||
67 | |||
68 | foreach ($pattern as $patternKey=>$patternValue){ |
||
69 | if(!$this->route->isMatchVaribleRegexPattern($patternValue)){ |
||
70 | if($patternValue!==$urlRoute[$patternKey]){ |
||
71 | $matches = false; |
||
72 | } |
||
73 | } |
||
74 | } |
||
75 | |||
76 | if($matches){ |
||
77 | |||
78 | $isArrayEqual = $this->route->checkArrayEqual($patternList,$urlRoute); |
||
79 | |||
80 | if($isArrayEqual===null){ |
||
81 | return $key; |
||
82 | } |
||
83 | return $isArrayEqual; |
||
84 | } |
||
85 | } |
||
86 | |||
87 | if(count($pattern)-1 == count(route())){ |
||
88 | if(preg_match('@\{[a-z]+\?\}@is',end($pattern))){ |
||
89 | return $key; |
||
90 | } |
||
148 | } |
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.