Passed
Push — master ( b80a23...857a85 )
by Gabriel
02:58
created

Waredesk::setClientSecret()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
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
    /**
22
     * @var Inventory
23
     */
24
    public $inventory;
25
26
    private $apiUrl;
27
    private $requestHandler;
28
29 17
    public function __construct(string $clientId, string $clientSecret, string $accessToken = null)
30
    {
31 17
        $this->apiUrl = self::PRODUCTION_API_URL;
32 17
        $this->requestHandler = new RequestHandler($clientId, $clientSecret, $accessToken, $this->apiUrl);
33 17
        $this->products = new Products($this->requestHandler);
34 17
        $this->codes = new Codes($this->requestHandler);
35 17
        $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...
36 17
        $this->inventory = new Inventory($this->requestHandler);
37 17
    }
38
39
    public function getApiUrl()
40
    {
41
        return $this->apiUrl;
42
    }
43
44 17
    public function setApiUrl($apiUrl)
45
    {
46 17
        $this->apiUrl = rtrim($apiUrl, '/');
47 17
        $this->requestHandler->setApiUrl($this->apiUrl);
48 17
    }
49
50
    public function getClientId(): string
51
    {
52
        return $this->requestHandler->getClientId();
53
    }
54
55 1
    public function setClientId(string $clientId = null)
56
    {
57 1
        $this->requestHandler->setClientId($clientId);
58 1
    }
59
60
    public function getClientSecret(): string
61
    {
62
        return $this->requestHandler->getClientSecret();
63
    }
64
65
    public function setClientSecret(string $clientSecret = null)
66
    {
67
        $this->requestHandler->setClientSecret($clientSecret);
68
    }
69
70 2
    public function getAccessToken(): string
71
    {
72 2
        return $this->requestHandler->getAccessToken();
73
    }
74
75 17
    public function setAccessToken(string $accessToken = null)
76
    {
77 17
        $this->requestHandler->setAccessToken($accessToken);
78 17
    }
79
80 17
    public function setMockHandler(HandlerStack $mockHandler = null)
81
    {
82 17
        $this->requestHandler->setMockHandler($mockHandler);
83 17
    }
84
}
85