Completed
Push — master ( 134b2d...f2c57a )
by Gabriel
02:40
created

Waredesk   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 70.97%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 4
dl 0
loc 72
ccs 22
cts 31
cp 0.7097
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getApiUrl() 0 4 1
A setApiUrl() 0 5 1
A getClientId() 0 4 1
A setClientId() 0 4 1
A getClientSecret() 0 4 1
A setClientSecret() 0 4 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 15
    public function __construct(string $clientId, string $clientSecret, string $accessToken = null)
25
    {
26 15
        $this->apiUrl = self::PRODUCTION_API_URL;
27 15
        $this->requestHandler = new RequestHandler($clientId, $clientSecret, $accessToken, $this->apiUrl);
28 15
        $this->products = new Products($this->requestHandler);
29 15
        $this->codes = new Codes($this->requestHandler);
30 15
        $this->categories = new Categories($this->requestHandler);
0 ignored issues
show
Bug introduced by
The property categories does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
31 15
    }
32
33
    public function getApiUrl()
34
    {
35
        return $this->apiUrl;
36
    }
37
38 15
    public function setApiUrl($apiUrl)
39
    {
40 15
        $this->apiUrl = rtrim($apiUrl, '/');
41 15
        $this->requestHandler->setApiUrl($this->apiUrl);
42 15
    }
43
44
    public function getClientId(): string
45
    {
46
        return $this->requestHandler->getClientId();
47
    }
48
49 1
    public function setClientId(string $clientId = null)
50
    {
51 1
        $this->requestHandler->setClientId($clientId);
52 1
    }
53
54
    public function getClientSecret(): string
55
    {
56
        return $this->requestHandler->getClientSecret();
57
    }
58
59
    public function setClientSecret(string $clientSecret = null)
60
    {
61
        $this->requestHandler->setClientSecret($clientSecret);
62
    }
63
64 2
    public function getAccessToken(): string
65
    {
66 2
        return $this->requestHandler->getAccessToken();
67
    }
68
69 15
    public function setAccessToken(string $accessToken = null)
70
    {
71 15
        $this->requestHandler->setAccessToken($accessToken);
72 15
    }
73
74 15
    public function setMockHandler(HandlerStack $mockHandler = null)
75
    {
76 15
        $this->requestHandler->setMockHandler($mockHandler);
77 15
    }
78
}
79