| Conditions | 10 |
| Paths | 2 |
| Total Lines | 45 |
| Code Lines | 16 |
| 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 |
||
| 102 | public function matchingUrlMethod($patterns,$urlMethod) |
||
| 103 | { |
||
| 104 | if(isset($urlMethod[0])){ |
||
| 105 | |||
| 106 | $list = []; |
||
| 107 | |||
| 108 | foreach ($patterns as $key=>$pattern){ |
||
| 109 | |||
| 110 | // if the initial value of the pattern data is present |
||
| 111 | // and the first value from urlmethod does not match |
||
| 112 | // and does not match the custom regex variable, |
||
| 113 | // we empty the contents of the data. |
||
| 114 | if(isset($pattern[0])){ |
||
| 115 | if($pattern[0] !== $urlMethod[0] && !$this->route->isMatchVaribleRegexPattern($pattern[0])){ |
||
| 116 | $list[$key] = []; |
||
| 117 | } |
||
| 118 | } |
||
| 119 | |||
| 120 | // if the contents of the directory are not normally emptied, |
||
| 121 | // we continue to save the list according to keyin status. |
||
| 122 | if(!isset($list[$key])){ |
||
| 123 | $list[$key] = $pattern; |
||
| 124 | } |
||
| 125 | |||
| 126 | // This is very important. |
||
| 127 | // Route matches can be variable-based or static string-based. |
||
| 128 | // In this case, we remove the other matches based on the static string match. |
||
| 129 | if(isset($pattern[0]) && $pattern[0]==$urlMethod[0]){ |
||
| 130 | |||
| 131 | // static matches will not be deleted retrospectively. |
||
| 132 | // this condition will check this. |
||
| 133 | if($this->unset===false){ |
||
| 134 | unset($list); |
||
| 135 | $this->unset = true; |
||
| 136 | } |
||
| 137 | |||
| 138 | $list[$key] = $pattern; |
||
| 139 | } |
||
| 140 | } |
||
| 141 | |||
| 142 | $patterns = $list; |
||
| 143 | $this->unset = true; |
||
| 144 | } |
||
| 145 | |||
| 146 | return $patterns; |
||
| 147 | } |
||
| 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.