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.

MPNSBase::getExpirationTime()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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
use Zbox\UnifiedPush\Exception\BadMethodCallException;
16
17
/**
18
 * Class MPNSBase
19
 * @package Zbox\UnifiedPush\Message\Type
20
 */
21
class MPNSBase extends MessageBase
22
{
23
    /**
24
     * MPNs does not support multicast sending
25
     */
26
    const MAX_RECIPIENTS_PER_MESSAGE_COUNT = 1;
27
28
    /**
29
     * Notification delivery interval
30
     *
31
     * @var int
32
     */
33
    protected $delayInterval;
34
35
    /**
36
     * @return string
37
     */
38
    public function getMessageType()
39
    {
40
        return NotificationServices::MICROSOFT_PUSH_NOTIFICATIONS_SERVICE;
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function getMPNSType()
47
    {
48
        return static::MESSAGE_TYPE;
49
    }
50
51
    /**
52
     * No expiration time available in MPN
53
     *
54
     * @throws BadMethodCallException
55
     */
56
    public function getExpirationTime()
57
    {
58
        throw new BadMethodCallException("No expiration time available in MPN");
59
    }
60
61
    /**
62
     * @return int
63
     */
64
    public function getDelayInterval()
65
    {
66
        if (!$this->delayInterval) {
67
            $this->setDelayInterval(static::DELAY_INTERVAL_IMMEDIATE);
68
        }
69
        return $this->delayInterval;
70
    }
71
72
    /**
73
     * @param int $delayInterval
74
     * @return $this
75
     */
76
    public function setDelayInterval($delayInterval)
77
    {
78
        if (!in_array($delayInterval, array(
79
            static::DELAY_INTERVAL_IMMEDIATE,
80
            static::DELAY_INTERVAL_450,
81
            static::DELAY_INTERVAL_900
82
        ))) {
83
            throw new InvalidArgumentException('Delivery interval must be equal one of predefined interval flag');
84
        }
85
        $this->delayInterval = $delayInterval;
86
87
        return $this;
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93
    public function validateRecipient($token)
94
    {
95
        if (base64_encode(base64_decode($token)) !== $token) {
96
            throw new InvalidArgumentException(sprintf(
97
                'Device token must be base64 string. Token given: "%s"',
98
                $token
99
            ));
100
        }
101
        return true;
102
    }
103
104
    /**
105
     * @return \ReflectionProperty[]
106
     */
107
    public function getPropertiesList()
108
    {
109
        $reflection = new \ReflectionObject($this);
110
        $properties = $reflection->getProperties(\ReflectionProperty::IS_PRIVATE);
111
112
        return $properties;
113
    }
114
}
115