Passed
Push — master ( 59a2ef...64aade )
by Hector Luis
02:16
created

Rest::request()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 4
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Gateway Client Class
6
 * @category    Ticaje
7
 * @author      Max Demian <[email protected]>
8
 */
9
10
namespace Ticaje\AConnector\Gateway\Client;
11
12
use Ticaje\AConnector\Interfaces\Implementors\Client\Rest\RestClientImplementorInterface;
13
use Ticaje\Contract\Factory\FactoryInterface;
14
use Ticaje\Contract\Patterns\Interfaces\Decorator\ResponderInterface;
15
16
use Ticaje\AConnector\Interfaces\Protocol\RestClientInterface;
17
18
/**
19
 * Class Rest
20
 * @package Ticaje\Connector\Gateway\Client
21
 */
22
class Rest extends Base implements RestClientInterface
23
{
24
    private $baseUriKey;
25
26
    /**
27
     * Rest constructor.
28
     * @param ResponderInterface $responder
29
     * @param FactoryInterface $clientFactory
30
     * @param RestClientImplementorInterface $implementor
31
     * @param string $baseUriKey
32
     */
33
    public function __construct(
34
        ResponderInterface $responder,
35
        FactoryInterface $clientFactory,
36
        RestClientImplementorInterface $implementor,
37
        string $baseUriKey
38
    ) {
39
        $this->baseUriKey = $baseUriKey;
40
        parent::__construct($responder, $clientFactory, $implementor);
41
    }
42
43
    /**
44
     * @inheritDoc
45
     */
46
    public function generateClient($credentials)
47
    {
48
        $client = $this->clientFactory->create([$this->baseUriKey => $credentials[self::BASE_URI_KEY]]);
49
        return $this->implementor->setClient($client);
0 ignored issues
show
Bug introduced by
The method setClient() does not exist on Ticaje\AConnector\Interfaces\ClientInterface. It seems like you code against a sub-type of Ticaje\AConnector\Interfaces\ClientInterface such as Ticaje\AConnector\Interf...entImplementorInterface or Ticaje\AConnector\Gatewa...ations\Client\Rest\Curl or Ticaje\AConnector\Gatewa...ions\Client\Rest\Guzzle. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
        return $this->implementor->/** @scrutinizer ignore-call */ setClient($client);
Loading history...
50
    }
51
52
    /**
53
     * @inheritDoc
54
     */
55
    public function request($verb, $endpoint, array $headers = [], array $params)
56
    {
57
        $result = $this->implementor->request($verb, $endpoint, $headers, $params);
0 ignored issues
show
Bug introduced by
The method request() does not exist on Ticaje\AConnector\Interfaces\ClientInterface. It seems like you code against a sub-type of Ticaje\AConnector\Interfaces\ClientInterface such as Ticaje\AConnector\Interf...col\RestClientInterface or Ticaje\AConnector\Interf...col\SoapClientInterface or Ticaje\AConnector\Gatewa...ations\Client\Rest\Curl or Ticaje\AConnector\Gatewa...ions\Client\Rest\Guzzle or Ticaje\AConnector\Gateway\Client\Rest or Ticaje\AConnector\Gateway\Client\Soap. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

57
        /** @scrutinizer ignore-call */ 
58
        $result = $this->implementor->request($verb, $endpoint, $headers, $params);
Loading history...
58
        return $this->responder->process($result);
59
    }
60
61
    /**
62
     * @inheritDoc
63
     */
64
    public function requestAsync($verb, $endpoint, array $headers = [], array $params)
65
    {
66
        $result = $this->implementor->requestAsync($verb, $endpoint, $headers, $params);
0 ignored issues
show
Bug introduced by
The method requestAsync() does not exist on Ticaje\AConnector\Interfaces\ClientInterface. It seems like you code against a sub-type of Ticaje\AConnector\Interfaces\ClientInterface such as Ticaje\AConnector\Interf...col\RestClientInterface or Ticaje\AConnector\Gatewa...ations\Client\Rest\Curl or Ticaje\AConnector\Gatewa...ions\Client\Rest\Guzzle or Ticaje\AConnector\Gateway\Client\Rest. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

66
        /** @scrutinizer ignore-call */ 
67
        $result = $this->implementor->requestAsync($verb, $endpoint, $headers, $params);
Loading history...
67
        return $this->responder->process($result);
68
    }
69
}
70