Passed
Push — master ( 664b37...040394 )
by Gabriel
02:14
created

Waredesk::getLogger()   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 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Waredesk;
4
5
use GuzzleHttp\HandlerStack;
6
use Psr\Log\LoggerInterface;
7
8
class Waredesk
9
{
10
    const PRODUCTION_API_URL = 'https://api.waredesk.com';
11
12
    /** @var Variables */
13
    public $variables;
14
    /** @var Products */
15
    public $products;
16
    /** @var Inventory */
17
    public $inventory;
18
19
    private $logger;
20
    private $apiUrl;
21
    private $requestHandler;
22
23 20
    public function __construct(string $clientId, string $clientSecret, string $accessToken = null, LoggerInterface $logger = null)
24
    {
25 20
        $this->logger = $logger;
26 20
        $this->apiUrl = self::PRODUCTION_API_URL;
27 20
        $this->requestHandler = new RequestHandler($clientId, $clientSecret, $accessToken, $this->apiUrl, $this->logger);
28 20
        $this->products = new Products($this->requestHandler);
29 20
        $this->variables = new Variables($this->requestHandler);
30 20
        $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 20
        $this->inventory = new Inventory($this->requestHandler);
32 20
    }
33
34
    public function getLogger(): ? LoggerInterface
35
    {
36
        return $this->logger;
37
    }
38
39 1
    public function setLogger(LoggerInterface $logger = null)
40
    {
41 1
        $this->logger = $logger;
42 1
        $this->requestHandler->setLogger($logger);
43 1
    }
44
45
    public function getApiUrl(): ? string
46
    {
47
        return $this->apiUrl;
48
    }
49
50 20
    public function setApiUrl(string $apiUrl)
51
    {
52 20
        $this->apiUrl = rtrim($apiUrl, '/');
53 20
        $this->requestHandler->setApiUrl($this->apiUrl);
54 20
    }
55
56
    public function getClientId(): string
57
    {
58
        return $this->requestHandler->getClientId();
59
    }
60
61 1
    public function setClientId(string $clientId = null)
62
    {
63 1
        $this->requestHandler->setClientId($clientId);
64 1
    }
65
66
    public function getClientSecret(): string
67
    {
68
        return $this->requestHandler->getClientSecret();
69
    }
70
71
    public function setClientSecret(string $clientSecret = null)
72
    {
73
        $this->requestHandler->setClientSecret($clientSecret);
74
    }
75
76 2
    public function getAccessToken(): string
77
    {
78 2
        return $this->requestHandler->getAccessToken();
79
    }
80
81 20
    public function setAccessToken(string $accessToken = null)
82
    {
83 20
        $this->requestHandler->setAccessToken($accessToken);
84 20
    }
85
86 20
    public function setMockHandler(HandlerStack $mockHandler = null)
87
    {
88 20
        $this->requestHandler->setMockHandler($mockHandler);
89 20
    }
90
}
91