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.

GCM::setDelayWhileIdle()   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\Message\Type;
11
12
use Zbox\UnifiedPush\Message\MessageBase;
13
use Zbox\UnifiedPush\NotificationService\NotificationServices;
14
use Zbox\UnifiedPush\Exception\InvalidArgumentException;
15
16
/**
17
 * Class GCM
18
 * @package Zbox\UnifiedPush\Message\Type
19
 */
20
class GCM extends MessageBase
21
{
22
    /**
23
     * It`s possible to send the same message to up to 1000 registration IDs in one request
24
     */
25
    const MAX_RECIPIENTS_PER_MESSAGE_COUNT = 1000;
26
27
    /**
28
     * Allow test the request without actually sending the message
29
     *
30
     * @var boolean
31
     */
32
    private $dryRun = false;
33
34
    /**
35
     * If there is already a message with the same collapse key (and registration ID)
36
     * stored and waiting for delivery, the old message will be discarded
37
     * and the new message will take its place
38
     *
39
     * @var string
40
     */
41
    private $collapseKey;
42
43
    /**
44
     * Message payload data
45
     *
46
     * @var array
47
     */
48
    private $payloadData;
49
50
    /**
51
     * If the device is connected but idle, the message will still be delivered right away
52
     * unless the delay_while_idle flag is set to true
53
     *
54
     * @var boolean
55
     */
56
    private $delayWhileIdle;
57
58
    /**
59
     * Package name of you application
60
     *
61
     * @var string
62
     */
63
    private $packageName;
64
65
    /**
66
     * @return string
67
     */
68
    public function getMessageType()
69
    {
70
        return NotificationServices::GOOGLE_CLOUD_MESSAGING;
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function getCollapseKey()
77
    {
78
        return $this->collapseKey;
79
    }
80
81
    /**
82
     * @param string $collapseKey
83
     * @return $this
84
     */
85
    public function setCollapseKey($collapseKey)
86
    {
87
        $this->collapseKey = $collapseKey;
88
        return $this;
89
    }
90
91
    /**
92
     * @return boolean
93
     */
94
    public function isDelayWhileIdle()
95
    {
96
        return $this->delayWhileIdle;
97
    }
98
99
    /**
100
     * @param boolean $delayWhileIdle
101
     * @return $this
102
     */
103
    public function setDelayWhileIdle($delayWhileIdle)
104
    {
105
        $this->delayWhileIdle = $delayWhileIdle;
106
        return $this;
107
    }
108
109
    /**
110
     * @return boolean
111
     */
112
    public function isDryRun()
113
    {
114
        return (bool) $this->dryRun;
115
    }
116
117
    /**
118
     * @param boolean $dryRun
119
     * @return $this
120
     */
121
    public function setDryRun($dryRun)
122
    {
123
        $this->dryRun = $dryRun;
124
        return $this;
125
    }
126
127
    /**
128
     * @return string
129
     */
130
    public function getPackageName()
131
    {
132
        return $this->packageName;
133
    }
134
135
    /**
136
     * @param string $packageName
137
     * @return $this
138
     */
139
    public function setPackageName($packageName)
140
    {
141
        $this->packageName = $packageName;
142
        return $this;
143
    }
144
145
    /**
146
     * @return array
147
     */
148
    public function getPayloadData()
149
    {
150
        return $this->payloadData;
151
    }
152
153
    /**
154
     * @param array $payloadData
155
     * @return $this
156
     */
157
    public function setPayloadData($payloadData)
158
    {
159
        $this->payloadData = $payloadData;
160
        return $this;
161
    }
162
163
    /**
164
     * {@inheritdoc}
165
     */
166
    public function validateRecipient($token)
167
    {
168
        if (!preg_match('#^[0-9a-z\-\_]+$#i', $token)) {
169
            throw new InvalidArgumentException(sprintf(
170
                'Device token must be mask "%s". Token given: "%s"',
171
                '^[0-9a-z\-\_]+$#i',
172
                $token
173
            ));
174
        }
175
        return true;
176
    }
177
}
178