ApiRequester::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
dl 0
loc 6
c 1
b 0
f 0
rs 10
cc 1
nc 1
nop 0
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