Base::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 1
nc 1
nop 3
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Api Class
6
 * @category    Ticaje
7
 * @author      Max Demian <[email protected]>
8
 */
9
10
namespace Ticaje\AeSdk\Api\Mediator;
11
12
use Ticaje\Contract\Patterns\Interfaces\Pool\PoolInterface;
13
14
use Ticaje\AConnector\Interfaces\ClientInterface;
15
16
use Ticaje\AeSdk\Infrastructure\Interfaces\Provider\Request\RequesterInterface;
17
use Ticaje\AeSdk\Infrastructure\Interfaces\DtoInterface;
18
19
use Ticaje\AeSdk\Domain\Interfaces\Request\ServiceRequestInterface;
20
21
/**
22
 * Class Base
23
 * @package Ticaje\AeSdk\Api\Mediator
24
 */
25
abstract class Base
26
{
27
    private $baseUri = 'http://gw.api.taobao.com/';
28
29
    protected $client;
30
31
    protected $requester;
32
33
    protected $pool;
34
35
    /**
36
     * Base constructor.
37
     * @param ClientInterface $client
38
     * @param RequesterInterface $requester
39
     * @param PoolInterface $pool
40
     */
41
    public function __construct(
42
        ClientInterface $client,
43
        RequesterInterface $requester,
44
        PoolInterface $pool
45
    ) {
46
        $this->client = $client;
47
        $this->requester = $requester;
48
        $this->pool = $pool;
49
        $this->client->generateClient(['base_uri' => $this->baseUri]);
0 ignored issues
show
Bug introduced by
The method generateClient() 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\Gateway\Client\Rest or Ticaje\AConnector\Gateway\Client\Soap 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

49
        $this->client->/** @scrutinizer ignore-call */ 
50
                       generateClient(['base_uri' => $this->baseUri]);
Loading history...
50
    }
51
52
    public function build(ServiceRequestInterface $serviceRequest, DtoInterface $dto)
53
    {
54
        $dto->setApiMethodName($serviceRequest->getApiMethodName());
0 ignored issues
show
Bug introduced by
The method getApiMethodName() does not exist on Ticaje\AeSdk\Domain\Inte...ServiceRequestInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Ticaje\AeSdk\Domain\Inte...ServiceRequestInterface. ( Ignorable by Annotation )

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

54
        $dto->setApiMethodName($serviceRequest->/** @scrutinizer ignore-call */ getApiMethodName());
Loading history...
Bug introduced by
The method setApiMethodName() does not exist on Ticaje\AeSdk\Infrastruct...Interfaces\DtoInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Ticaje\AeSdk\Infrastruct...est\RequestDtoInterface. Are you sure you never get one of those? ( Ignorable by Annotation )

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

54
        $dto->/** @scrutinizer ignore-call */ 
55
              setApiMethodName($serviceRequest->getApiMethodName());
Loading history...
55
        $dto->setRequest($serviceRequest->getRequest());
0 ignored issues
show
Bug introduced by
The method setRequest() does not exist on Ticaje\AeSdk\Infrastruct...Interfaces\DtoInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Ticaje\AeSdk\Infrastruct...est\RequestDtoInterface. Are you sure you never get one of those? ( Ignorable by Annotation )

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

55
        $dto->/** @scrutinizer ignore-call */ 
56
              setRequest($serviceRequest->getRequest());
Loading history...
56
        $params = $this->requester->compile($dto);
57
        return $params;
58
    }
59
}
60