Passed
Push — master ( 37b4ec...6e8e43 )
by Darío
02:14 queued 10s
created

ClientAdapter::setHandler()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace EasyHttp\LayerContracts\Tests\Unit\Example;
4
5
use EasyHttp\LayerContracts\Contracts\HttpClientAdapter;
6
use EasyHttp\LayerContracts\Contracts\HttpClientRequest;
7
use EasyHttp\LayerContracts\Contracts\HttpClientResponse;
8
9
class ClientAdapter implements HttpClientAdapter
10
{
11
    protected $handler;
12
13
    public function setHandler(callable $handler): void
14
    {
15
        $this->handler = $handler;
16
    }
17
18
    public function request(HttpClientRequest $request): HttpClientResponse
19
    {
20
        $response = $this->call($request->getMethod(), $request->getUri());
21
        return new ClientResponse($response);
22
    }
23
24
    private function call(string $method, string $uri): array
0 ignored issues
show
Unused Code introduced by
The parameter $method is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

24
    private function call(/** @scrutinizer ignore-unused */ string $method, string $uri): array

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $uri is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

24
    private function call(string $method, /** @scrutinizer ignore-unused */ string $uri): array

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
25
    {
26
        if ($this->handler) {
27
            return call_user_func($this->handler);
28
        }
29
30
        return [
31
            'status' => 200,
32
            'headers' => ['Server' => 'Apache/2.4.38 (Debian)'],
33
            'body' => '{"key":"value"}',
34
        ];
35
    }
36
}
37