BodyParser   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
ccs 3
cts 3
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 4 1
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