Request::getWorker()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 8
ccs 0
cts 7
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * ActiveRecord for API
4
 *
5
 * @link      https://github.com/hiqdev/yii2-hiart
6
 * @package   yii2-hiart
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\hiart\proxy;
12
13
use GuzzleHttp\Exception\BadResponseException;
0 ignored issues
show
Bug introduced by
The type GuzzleHttp\Exception\BadResponseException 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...
14
15
abstract class Request extends \hiqdev\hiart\AbstractRequest
16
{
17
    /**
18
     * @var object
19
     */
20
    protected $worker;
21
22
    abstract protected function createWorker();
23
24
    public function send($options = [])
25
    {
26
        try {
27
            $responseWorker = $this->getHandler()->send($this->getWorker(), $options);
28
        } catch (BadResponseException $exception) {
29
            $responseWorker = $exception->getResponse();
30
        }
31
32
        return new $this->responseClass($this, $responseWorker);
33
    }
34
35
    /**
36
     * @return object Worker
37
     */
38
    public function getWorker()
39
    {
40
        if ($this->worker === null) {
41
            $this->build();
42
            $this->worker = $this->createWorker();
43
        }
44
45
        return $this->worker;
46
    }
47
}
48