Passed
Push — master ( 89f24e...8c4dad )
by Sylvain
08:05
created

GraphQLHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 21
ccs 0
cts 8
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 5 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ecodev\Felix\Handler;
6
7
use Ecodev\Felix\Api\Server;
8
use Laminas\Diactoros\Response\JsonResponse;
9
use Psr\Http\Message\ResponseInterface;
10
use Psr\Http\Message\ServerRequestInterface;
11
use Psr\Http\Server\RequestHandlerInterface;
12
13
final class GraphQLHandler implements RequestHandlerInterface
14
{
15
    /**
16
     * @var Server
17
     */
18
    private $server;
19
20
    public function __construct(Server $server)
21
    {
22
        $this->server = $server;
23
    }
24
25
    /**
26
     * Process an incoming server request and return a response, optionally delegating
27
     * to the next middleware component to create the response.
28
     */
29
    public function handle(ServerRequestInterface $request): ResponseInterface
30
    {
31
        $response = $this->server->execute($request);
32
33
        return new JsonResponse($response);
34
    }
35
}
36