Conditions | 12 |
Paths | 83 |
Total Lines | 35 |
Code Lines | 29 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 156 |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
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 |
||
47 | { |
||
48 | $response = $response->withProtocolVersion($serverRequest->getProtocolVersion()); |
||
49 | |||
50 | try { |
||
51 | $APIRequest = $this->requestFactory->create($serverRequest); |
||
52 | |||
53 | try { |
||
54 | $APIResponse = $this->server->handleRequest($APIRequest); |
||
55 | |||
56 | $response = $response->withStatus(200, "200 OK"); |
||
57 | $response = $response->withAddedHeader("Content-Type", $APIResponse->getMIMEType()); |
||
58 | $response = $response->withAddedHeader("Content-Length", $APIResponse->getAsDataStream()->getSize()); |
||
59 | $response = $response->withBody($APIResponse->getAsDataStream()); |
||
60 | } catch (InvalidAPIKeyException $e) { |
||
61 | $response = $response->withStatus(400, "400 Bad Request"); |
||
62 | } catch (UnknownEndpointException $e) { |
||
63 | $response = $response->withStatus(404, "404 Not Found"); |
||
64 | } catch (NotAcceptableResponseTypeException $e) { |
||
65 | $response = $response->withStatus(406, "406 Not Acceptable"); |
||
66 | } catch (AccessDeniedException $e) { |
||
67 | $response = $response->withStatus(403, "403 Access Denied"); |
||
68 | } catch (ThrottleLimitExceededException $e) { |
||
69 | $response = $response->withStatus(429, "429 Too Many Requests"); |
||
70 | } catch (MethodNotFoundException | \Throwable $e) { |
||
1 ignored issue
–
show
|
|||
71 | $response = $response->withStatus(500, "500 Internal Server Error"); |
||
72 | } |
||
73 | } catch (InvalidRequestURLException $e) { |
||
74 | $response = $response->withStatus(400, "400 Bad Request"); |
||
75 | } catch (MethodNotFoundException | \Throwable $e) { |
||
1 ignored issue
–
show
|
|||
76 | $response = $response->withStatus(500, "500 Internal Server Error"); |
||
77 | } |
||
78 | return $response; |
||
79 | } |
||
80 | |||
81 | public function dumpResponse(ResponseInterface $response) { |
||
82 | header(sprintf("HTTP/%s", $response->getProtocolVersion())); |
||
98 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.