Completed
Push — master ( e6ba08...9dbf89 )
by Gabriel
02:34
created

Waredesk   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 70%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 3
dl 0
loc 71
ccs 21
cts 30
cp 0.7
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getApiUrl() 0 4 1
A getClientId() 0 4 1
A getClientSecret() 0 4 1
A setClientSecret() 0 4 1
A setApiUrl() 0 5 1
A setClientId() 0 4 1
A __construct() 0 7 1
A getAccessToken() 0 4 1
A setAccessToken() 0 4 1
A setMockHandler() 0 4 1
1
<?php
2
3
namespace Waredesk;
4
5
use GuzzleHttp\HandlerStack;
6
7
class Waredesk
8
{
9
    const PRODUCTION_API_URL = 'https://api.waredesk.com';
10
11
    /**
12
     * @var Codes
13
     */
14
    public $codes;
15
16
    /**
17
     * @var Products
18
     */
19
    public $products;
20
21
    private $apiUrl;
22
    private $requestHandler;
23
24 9
    public function __construct(string $clientId, string $clientSecret, string $accessToken = null)
25
    {
26 9
        $this->apiUrl = self::PRODUCTION_API_URL;
27 9
        $this->requestHandler = new RequestHandler($clientId, $clientSecret, $accessToken, $this->apiUrl);
28 9
        $this->products = new Products($this->requestHandler);
29 9
        $this->codes = new Codes($this->requestHandler);
30 9
    }
31
32
    public function getApiUrl()
33
    {
34
        return $this->apiUrl;
35
    }
36
37 9
    public function setApiUrl($apiUrl)
38
    {
39 9
        $this->apiUrl = rtrim($apiUrl, '/');
40 9
        $this->requestHandler->setApiUrl($this->apiUrl);
41 9
    }
42
43
    public function getClientId(): string
44
    {
45
        return $this->requestHandler->getClientId();
46
    }
47
48 1
    public function setClientId(string $clientId = null)
49
    {
50 1
        $this->requestHandler->setClientId($clientId);
51 1
    }
52
53
    public function getClientSecret(): string
54
    {
55
        return $this->requestHandler->getClientSecret();
56
    }
57
58
    public function setClientSecret(string $clientSecret = null)
59
    {
60
        $this->requestHandler->setClientSecret($clientSecret);
61
    }
62
63 2
    public function getAccessToken(): string
64
    {
65 2
        return $this->requestHandler->getAccessToken();
66
    }
67
68 9
    public function setAccessToken(string $accessToken = null)
69
    {
70 9
        $this->requestHandler->setAccessToken($accessToken);
71 9
    }
72
73 9
    public function setMockHandler(HandlerStack $mockHandler = null)
74
    {
75 9
        $this->requestHandler->setMockHandler($mockHandler);
76 9
    }
77
}
78