GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ServiceClientBase::setCredentials()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
/*
4
 * (c) Alexander Zhukov <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Zbox\UnifiedPush\NotificationService;
11
12
use Zbox\UnifiedPush\Utils\ClientCredentials\CredentialsInterface;
13
use Zbox\UnifiedPush\Notification\Notification;
14
use Zbox\UnifiedPush\Exception\InvalidArgumentException;
15
16
/**
17
 * Class ServiceClientBase
18
 * @package Zbox\UnifiedPush\NotificationService
19
 */
20
abstract class ServiceClientBase implements ServiceClientInterface
21
{
22
    /**
23
     * @var array
24
     */
25
    protected $serviceURL;
26
27
    /**
28
     * @var CredentialsInterface
29
     */
30
    protected $credentials;
31
32
    /**
33
     * @var Notification
34
     */
35
    protected $notification;
36
37
    /**
38
     * @var mixed
39
     */
40
    protected $serviceClient;
41
42
    /**
43
     * @param array $serviceUrl
44
     * @param CredentialsInterface $credentials
45
     */
46
    public function __construct($serviceUrl, CredentialsInterface $credentials)
47
    {
48
        $this->setServiceURL($serviceUrl);
49
        $this->setCredentials($credentials);
50
51
        $this->createClient();
52
53
        return $this;
0 ignored issues
show
Bug introduced by
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
54
    }
55
56
    abstract protected function createClient();
57
58
    /**
59
     * @param array $serviceURL
60
     * @return $this
61
     */
62
    public function setServiceURL($serviceURL)
63
    {
64
        $this->serviceURL = $serviceURL;
65
        return $this;
66
    }
67
68
    /**
69
     * @return array
70
     */
71
    public function getServiceURL()
72
    {
73
        return $this->serviceURL;
74
    }
75
76
    /**
77
     * @param CredentialsInterface $credentials
78
     * @return $this
79
     */
80
    public function setCredentials(CredentialsInterface $credentials)
81
    {
82
        $this->credentials = $credentials;
83
        return $this;
84
    }
85
86
    /**
87
     * @return CredentialsInterface
88
     */
89
    public function getCredentials()
90
    {
91
        return $this->credentials;
92
    }
93
94
    /**
95
     * @param Notification $notification
96
     * @return $this
97
     */
98
    public function setNotification(Notification $notification)
99
    {
100
        $this->notification = $notification;
101
        return $this;
102
    }
103
104
    /**
105
     * @return Notification
106
     */
107
    public function getNotificationOrThrowException()
108
    {
109
        if (empty($this->notification)) {
110
            throw new InvalidArgumentException('Missing notification');
111
        }
112
113
        return $this->notification;
114
    }
115
116
    /**
117
     * @return mixed
118
     */
119
    public function getClientConnection()
120
    {
121
        return $this->serviceClient;
122
    }
123
}
124