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

ClientAdapter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
c 1
b 0
f 1
dl 0
loc 25
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A request() 0 4 1
A setHandler() 0 3 1
A call() 0 10 2
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