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

Service   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sendRequest() 0 3 1
A __construct() 0 6 1
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