Client::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PublishingKit\HttpProxy;
6
7
use Http\Client\HttpClient;
8
use Psr\Http\Message\RequestInterface;
9
use Psr\Http\Message\ResponseInterface;
10
11
final class Client implements HttpClient
12
{
13
    /**
14
     * @var callable
15
     * @psalm-var callable(RequestInterface): ResponseInterface
16
     */
17
    private $callback;
18 3
19
    /**
20 3
     * @param callable $callback
21 3
     * @psalm-param callable(RequestInterface): ResponseInterface $callback
22
     */
23
    public function __construct(callable $callback)
24
    {
25
        $this->callback = $callback;
26 3
    }
27
28 3
    /**
29 3
     * {@inheritDoc}
30
     */
31
    public function sendRequest(RequestInterface $request): ResponseInterface
32
    {
33
        $callback = $this->callback;
34
        return $callback($request);
35
    }
36
}
37