GuzzleHandler   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 4
c 2
b 0
f 0
dl 0
loc 27
ccs 5
cts 5
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of coisa/http.
5
 *
6
 * (c) Felipe Sayão Lobato Abreu <[email protected]>
7
 *
8
 * This source file is subject to the license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
declare(strict_types=1);
13
14
namespace CoiSA\Http\Handler;
15
16
use GuzzleHttp\ClientInterface;
17
use Psr\Http\Message\ResponseInterface;
18
use Psr\Http\Message\ServerRequestInterface;
19
use Psr\Http\Server\RequestHandlerInterface;
20
21
/**
22
 * Class GuzzleHandler
23
 *
24
 * @package CoiSA\Http\Handler
25
 */
26
final class GuzzleHandler implements RequestHandlerInterface
27
{
28
    /**
29
     * @var ClientInterface
30
     */
31
    private $client;
32
33
    /**
34
     * GuzzleHandler constructor.
35
     *
36
     * @param ClientInterface $client
37
     */
38 3
    public function __construct(ClientInterface $client)
39
    {
40 3
        $this->client = $client;
41 3
    }
42
43
    /**
44
     * @param ServerRequestInterface $request
45
     *
46
     * @throws \GuzzleHttp\Exception\GuzzleException
47
     *
48
     * @return ResponseInterface
49
     */
50 1
    public function handle(ServerRequestInterface $request): ResponseInterface
51
    {
52 1
        return $this->client->send($request);
53
    }
54
}
55