Passed
Pull Request — master (#8)
by Thomas
11:44 queued 13s
created

Gateway   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 6
eloc 16
c 2
b 1
f 0
dl 0
loc 48
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getOperationPool() 0 3 1
A getRequestBuilder() 0 3 1
A __construct() 0 7 1
A getDataObjectFactory() 0 3 1
A getServiceFactory() 0 3 1
A getClient() 0 3 1
1
<?php
2
/**
3
 * Copyright © Thomas Klein, All rights reserved.
4
 * See LICENSE bundled with this library for license details.
5
 */
6
declare(strict_types=1);
7
8
namespace Zoho\Desk;
9
10
use Zoho\Desk\Client\ConfigProviderInterface;
11
use Zoho\Desk\Client\RequestBuilder;
12
use Zoho\Desk\Model\DataObjectFactory;
13
use Zoho\Desk\Model\OperationPool;
14
use Zoho\Desk\OAuth\Client;
15
use Zoho\Desk\Service\ServiceFactory;
16
17
/**
18
 * @api
19
 */
20
final class Gateway
21
{
22
    private Client $client;
23
24
    private RequestBuilder $requestBuilder;
25
26
    private DataObjectFactory $dataObjectFactory;
27
28
    private OperationPool $operationPool;
29
30
    private ServiceFactory $serviceFactory;
31
32
    public function __construct(ConfigProviderInterface $configProvider, array $registeredEntityTypes = [])
33
    {
34
        $this->client = new Client($configProvider);
35
        $this->requestBuilder = new RequestBuilder($this->client);
36
        $this->dataObjectFactory = new DataObjectFactory($registeredEntityTypes);
37
        $this->operationPool = new OperationPool($this->requestBuilder, $this->dataObjectFactory);
0 ignored issues
show
Deprecated Code introduced by
The class Zoho\Desk\Model\OperationPool has been deprecated. ( Ignorable by Annotation )

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

37
        $this->operationPool = /** @scrutinizer ignore-deprecated */ new OperationPool($this->requestBuilder, $this->dataObjectFactory);
Loading history...
38
        $this->serviceFactory = new ServiceFactory($this->requestBuilder, $this->dataObjectFactory);
39
    }
40
41
    public function getDataObjectFactory(): DataObjectFactory
42
    {
43
        return $this->dataObjectFactory;
44
    }
45
46
    /**
47
     * @deprecated
48
     * @see Gateway::getServiceFactory
49
     */
50
    public function getOperationPool(): OperationPool
51
    {
52
        return $this->operationPool;
53
    }
54
55
    public function getServiceFactory(): ServiceFactory
56
    {
57
        return $this->serviceFactory;
58
    }
59
60
    public function getClient(): Client
61
    {
62
        return $this->client;
63
    }
64
65
    public function getRequestBuilder(): RequestBuilder
66
    {
67
        return $this->requestBuilder;
68
    }
69
}
70