Passed
Push — develop ( bc7c49...ecfe6e )
by Fabian
01:26
created

Service::getClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cakasim\Payone\Sdk\Api;
6
7
use Cakasim\Payone\Sdk\AbstractService;
8
use Cakasim\Payone\Sdk\Api\Client\ClientExceptionInterface;
9
use Cakasim\Payone\Sdk\Api\Client\ClientInterface;
10
use Cakasim\Payone\Sdk\Api\Client\ErrorResponseExceptionInterface;
11
use Cakasim\Payone\Sdk\Api\Message\RequestInterface;
12
use Cakasim\Payone\Sdk\Api\Message\ResponseInterface;
13
use Psr\Container\ContainerInterface;
14
15
/**
16
 * The API service.
17
 *
18
 * @author Fabian Böttcher <[email protected]>
19
 * @since 0.1.0
20
 */
21
class Service extends AbstractService
22
{
23
    /**
24
     * @var ClientInterface The API client.
25
     */
26
    protected $client;
27
28
    /**
29
     * Constructs the API service.
30
     *
31
     * @inheritDoc
32
     * @param ClientInterface $client The API client.
33
     */
34
    public function __construct(
35
        ContainerInterface $container,
36
        ClientInterface $client
37
    ) {
38
        parent::__construct($container);
39
        $this->client = $client;
40
    }
41
42
    /**
43
     * Sends the provided request message and populates
44
     * the provided response message with the API response.
45
     *
46
     * @param RequestInterface $request The request message to send.
47
     * @param ResponseInterface $response The response message to populate with the API response.
48
     * @throws ClientExceptionInterface If sending fails.
49
     * @throws ErrorResponseExceptionInterface If the response is a PAYONE API error.
50
     */
51
    public function sendRequest(RequestInterface $request, ResponseInterface $response): void
52
    {
53
        $this->client->sendRequest($request, $response);
54
    }
55
}
56