BodyParser::process()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace App\Middleware;
4
5
use Zend\Diactoros\Response\HtmlResponse;
6
use Psr\Http\Message\ServerRequestInterface;
7
use Interop\Http\ServerMiddleware\DelegateInterface;
8
use Interop\Http\ServerMiddleware\MiddlewareInterface;
9
10
class BodyParser implements MiddlewareInterface
11
{
12
    /**
13
     * PSR-15 middleware callback
14
     *
15
     * @param ServerRequestInterface $request
16
     * @param DelegateInterface $delegate
17
     * @return Psr\Http\Message\ServerRequestInterface
0 ignored issues
show
Bug introduced by
The type App\Middleware\Psr\Http\...\ServerRequestInterface was not found. Did you mean Psr\Http\Message\ServerRequestInterface? If so, make sure to prefix the type with \.
Loading history...
18
     */
19 1
    public function process(ServerRequestInterface $request, DelegateInterface $delegate)
20
    {
21 1
        return $delegate->process(
0 ignored issues
show
Bug Best Practice introduced by
The expression return $delegate->proces...est->getBody(), true))) returns the type Psr\Http\Message\ResponseInterface which is incompatible with the documented return type App\Middleware\Psr\Http\...\ServerRequestInterface.
Loading history...
22 1
            $request->withAttribute('body', json_decode($request->getBody(), true))
23
        );
24
    }
25
}
26