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.
Completed
Push — master ( 71c569...6c5ffd )
by Alexander
02:31
created

MPNSBase::createPayload()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 27
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 27
rs 8.8571
cc 3
eloc 17
nc 3
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\Notification\Type;
11
12
use Zbox\UnifiedPush\Message\Type\MPNSBase as MPNSMessage;
13
/**
14
 * Class MPNSBase
15
 * @package Zbox\UnifiedPush\Message\Type
16
 */
17
class MPNSBase
18
{
19
    /**
20
     * The maximum size allowed for MPNS message payload is 3K bytes
21
     */
22
    const PAYLOAD_MAX_LENGTH = 3072;
23
24
    /**
25
     * MPNs does not support multicast sending
26
     */
27
    const MAX_RECIPIENTS_PER_MESSAGE_COUNT = 1;
28
29
    /**
30
     * Notification delivery interval
31
     *
32
     * @var int
33
     */
34
    protected $delayInterval;
35
36
    /**
37
     * @param MPNSMessage $message
38
     * @return \DOMDocument
39
     */
40
    public function createPayload(MPNSMessage $message)
41
    {
42
        $messageType = ucfirst($message->getMPNSType());
43
44
        $document      = new \DOMDocument("1.0", "utf-8");
45
        $baseElement  = $document->createElement("wp:Notification");
46
        $baseElement->setAttribute("xmlns:wp", "WPNotification");
47
        $document->appendChild($baseElement);
48
49
        $rootElement = $document->createElement("wp:" . $messageType);
50
        $baseElement->appendChild($rootElement);
51
52
        foreach ($message->getPropertiesList() as $property)
53
        {
54
            $propertyName   = ucfirst($property->getName());
55
            $getterName     = 'get' . $propertyName;
56
            $value          = $this->$getterName();
57
58
            if ($value) {
59
                $name    = "wp:" . $propertyName;
60
                $element = $document->createElement($name, $value);
61
                $rootElement->appendChild($element);
62
            }
63
        }
64
65
        return $message;
66
    }
67
68
    /**
69
     * @param \DOMDocument $payload
70
     * @return string
71
     */
72
    public function packPayload($payload)
73
    {
74
        return $payload->saveXML();
75
    }
76
}
77