ApiRequester   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
dl 0
loc 27
c 3
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handleRequest() 0 4 1
A __construct() 0 6 1
1
<?php
2
3
namespace ByJG\ApiTools;
4
5
use ByJG\Util\CurlException;
0 ignored issues
show
Bug introduced by
The type ByJG\Util\CurlException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use ByJG\Util\HttpClient;
7
use ByJG\Util\Psr7\MessageException;
0 ignored issues
show
Bug introduced by
The type ByJG\Util\Psr7\MessageException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use ByJG\Util\Psr7\Response;
9
use Psr\Http\Message\RequestInterface;
10
use Psr\Http\Message\ResponseInterface;
11
12
/**
13
 * Request handler based on ByJG HttpClient (WebRequest) .
14
 */
15
class ApiRequester extends AbstractRequester
16
{
17
    /** @var HttpClient */
18
    private $httpClient;
19
20
    /**
21
     * ApiRequester constructor.
22
     * @throws MessageException
23
     */
24
    public function __construct()
25
    {
26
        $this->httpClient = HttpClient::getInstance()
27
            ->withNoFollowRedirect();
28
29
        parent::__construct();
30
    }
31
32
    /**
33
     * @param RequestInterface $request
34
     * @return Response|ResponseInterface
35
     * @throws CurlException
36
     * @throws MessageException
37
     */
38
    protected function handleRequest(RequestInterface $request)
39
    {
40
        $request = $request->withHeader("User-Agent", "ByJG Swagger Test");
41
        return $this->httpClient->sendRequest($request);
42
    }
43
}
44