Completed
Push — master ( ecff25...470e9b )
by Oleksandr
12s
created

EpiserverApiAdapter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 8
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 3
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Zed\Episerver\Business\Api\Adapter;
9
10
use Generated\Shared\Transfer\EpiserverRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\EpiserverRequestTransfer 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...
11
use Generated\Shared\Transfer\EpiserverResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...iserverResponseTransfer 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...
12
use SprykerEco\Zed\Episerver\Business\Api\Adapter\Http\HttpAdapterInterface;
13
use SprykerEco\Zed\Episerver\Business\Api\Request\RequestUrlBuilderInterface;
14
use SprykerEco\Zed\Episerver\Business\Api\Response\ResponseConverterInterface;
15
16
class EpiserverApiAdapter implements EpiserverApiAdapterInterface
17
{
18
    /**
19
     * @var \SprykerEco\Zed\Episerver\Business\Api\Adapter\Http\HttpAdapterInterface
20
     */
21
    protected $httpAdapter;
22
23
    /**
24
     * @var \SprykerEco\Zed\Episerver\Business\Api\Request\RequestUrlBuilderInterface
25
     */
26
    protected $requestUrlBuilder;
27
28
    /**
29
     * @var \SprykerEco\Zed\Episerver\Business\Api\Response\ResponseConverterInterface
30
     */
31
    protected $responseConverter;
32
33
    /**
34
     * @param \SprykerEco\Zed\Episerver\Business\Api\Adapter\Http\HttpAdapterInterface $httpAdapter
35
     * @param \SprykerEco\Zed\Episerver\Business\Api\Request\RequestUrlBuilderInterface $requestUrlBuilder
36
     * @param \SprykerEco\Zed\Episerver\Business\Api\Response\ResponseConverterInterface $responseConverter
37
     */
38
    public function __construct(
39
        HttpAdapterInterface $httpAdapter,
40
        RequestUrlBuilderInterface $requestUrlBuilder,
41
        ResponseConverterInterface $responseConverter
42
    ) {
43
        $this->httpAdapter = $httpAdapter;
44
        $this->requestUrlBuilder = $requestUrlBuilder;
45
        $this->responseConverter = $responseConverter;
46
    }
47
48
    /**
49
     * @param \Generated\Shared\Transfer\EpiserverRequestTransfer $episerverRequestTransfer
50
     *
51
     * @return \Generated\Shared\Transfer\EpiserverResponseTransfer
52
     */
53
    public function sendRequest(EpiserverRequestTransfer $episerverRequestTransfer): EpiserverResponseTransfer
54
    {
55
        $requestUrl = $this->requestUrlBuilder->buildUrl($episerverRequestTransfer);
56
57
        $response = $this->httpAdapter->sendGetRequest($requestUrl);
58
59
        return $this->responseConverter->convertResponse($response);
60
    }
61
}
62