| Conditions | 15 |
| Paths | 240 |
| Total Lines | 71 |
| Code Lines | 50 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 59 | public function parseRequest(Message\Uri $uri = null) |
||
| 60 | { |
||
| 61 | $this->uri = is_null($uri) ? server_request()->getUri() : $uri; |
||
| 62 | $uriSegments = $this->uri->getSegments()->getParts(); |
||
| 63 | $uriString = $this->uri->getSegments()->getString(); |
||
| 64 | |||
| 65 | if($this->uri->getSegments()->getTotalParts()) { |
||
| 66 | if(strpos(end($uriSegments), '.json') !== false) { |
||
| 67 | output()->setContentType('application/json'); |
||
| 68 | $endSegment = str_replace('.json', '', end($uriSegments)); |
||
| 69 | array_pop($uriSegments); |
||
| 70 | array_push($uriSegments, $endSegment); |
||
| 71 | $this->uri = $this->uri->withSegments(new Message\Uri\Segments($uriSegments)); |
||
| 72 | $uriString = $this->uri->getSegments()->getString(); |
||
| 73 | } elseif(strpos(end($uriSegments), '.xml') !== false) { |
||
| 74 | output()->setContentType('application/xml'); |
||
| 75 | $endSegment = str_replace('.xml', '', end($uriSegments)); |
||
| 76 | array_pop($uriSegments); |
||
| 77 | array_push($uriSegments, $endSegment); |
||
| 78 | $this->uri = $this->uri->withSegments(new Message\Uri\Segments($uriSegments)); |
||
| 79 | $uriString = $this->uri->getSegments()->getString(); |
||
| 80 | } |
||
| 81 | } else { |
||
| 82 | $uriPath = urldecode( |
||
| 83 | parse_url($_SERVER[ 'REQUEST_URI' ], PHP_URL_PATH) |
||
| 84 | ); |
||
| 85 | |||
| 86 | $uriPathParts = explode('public/', $uriPath); |
||
| 87 | $uriPath = end($uriPathParts); |
||
| 88 | |||
| 89 | if ($uriPath !== '/') { |
||
| 90 | $uriString = $uriPath; |
||
| 91 | $uriSegments = array_filter(explode('/', $uriString)); |
||
| 92 | |||
| 93 | $this->uri = $this->uri->withSegments(new Message\Uri\Segments($uriSegments)); |
||
| 94 | $uriString = $this->uri->getSegments()->getString(); |
||
| 95 | } |
||
| 96 | } |
||
| 97 | |||
| 98 | if ($this->addresses instanceof Router\Addresses) { |
||
| 99 | // Domain routing |
||
| 100 | if (null !== ($domain = $this->addresses->getDomain())) { |
||
| 101 | if (is_array($domain)) { |
||
| 102 | $uriSegments = array_merge($domain, $uriSegments); |
||
| 103 | $this->uri = $this->uri->withSegments(new Message\Uri\Segments($uriSegments)); |
||
| 104 | $uriString = $this->uri->getSegments()->getString(); |
||
| 105 | } |
||
| 106 | } elseif (false !== ($subdomain = $this->uri->getSubdomain())) { |
||
| 107 | if (is_array($subdomain)) { |
||
| 108 | $uriSegments = array_merge($subdomain, $uriSegments); |
||
| 109 | $this->uri = $this->uri->withSegments(new Message\Uri\Segments($uriSegments)); |
||
| 110 | $uriString = $this->uri->getSegments()->getString(); |
||
| 111 | } |
||
| 112 | } |
||
| 113 | } |
||
| 114 | |||
| 115 | // Try to translate from uri string |
||
| 116 | if (false !== ($action = $this->addresses->getTranslation($uriString))) { |
||
| 117 | if ( ! $action->isValidHttpMethod(server_request()->getMethod()) && ! $action->isAnyHttpMethod()) { |
||
| 118 | output()->sendError(405); |
||
| 119 | } else { |
||
| 120 | if (false !== ($parseSegments = $action->getParseUriString($uriString))) { |
||
| 121 | $uriSegments = $parseSegments; |
||
| 122 | } else { |
||
| 123 | $uriSegments = []; |
||
| 124 | } |
||
| 125 | |||
| 126 | $this->uri = $this->uri->withSegments(new Message\Uri\Segments($uriSegments)); |
||
| 127 | $uriString = $this->uri->getSegments()->getString(); |
||
| 128 | |||
| 129 | $this->parseAction($action, $uriSegments); |
||
| 130 | } |
||
| 270 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths