| Conditions | 1 |
| Paths | 1 |
| Total Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
| 19 | { |
||
| 20 | $id = (int) $request->getQueryParams()['id']; |
||
|
|
|||
| 21 | $uri = $request->getUri(); |
||
| 22 | |||
| 23 | $hal = [ |
||
| 24 | '_links' => [ |
||
| 25 | 'self' => [ |
||
| 26 | 'href' => $uri->getScheme() . '://' . $uri->getHost() . $uri->getPath(), |
||
| 27 | ] |
||
| 28 | ], |
||
| 29 | ]; |
||
| 30 | |||
| 31 | $response = $handler->handle($request); |
||
| 32 | |||
| 33 | $data = json_decode($response->getBody()->getContents(), true); |
||
| 34 | $data = array_merge($hal, $data); |
||
| 35 | |||
| 36 | $body = $response->getBody(); |
||
| 37 | $body->rewind(); |
||
| 38 | $body->write(json_encode($data)); |
||
| 39 | |||
| 40 | return $response->withBody($body); |
||
| 41 | } |
||
| 42 | } |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.