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
Pull Request — master (#58)
by Lukas
05:48
created

OneSignalMessage::incrementIosBadgeCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace NotificationChannels\OneSignal;
4
5
use Illuminate\Support\Arr;
6
use NotificationChannels\OneSignal\Traits\OneSignalHelpers;
7
8
class OneSignalMessage
9
{
10
    use OneSignalHelpers;
11
12
13
    /** @var array */
14
    protected $data = [];
15
16
17
    /** @var array */
18
    protected $payload = [];
19
20
    /**
21
     * @param string $body
22
     *
23
     * @return static
24
     */
25 1
    public static function create($body = '')
26
    {
27 1
        return new static($body);
28
    }
29
30
    /**
31
     * @param string $body
32
     */
33 20
    public function __construct($body = '')
34
    {
35 20
       $this->body($body);
36 20
    }
37
38
    /**
39
     * Set the message body.
40
     *
41
     * @param string $value
42
     *
43
     * @return $this
44
     */
45 20
    public function body($value)
46
    {
47 20
        if(is_array($value)){
48
            $this->setParameter('contents',$value);
49
        } else {
50 20
            $this->setParameter('contents',['en' => $value]);
51
        }
52 20
        return $this;
53
    }
54
55
    /**
56
     * Set the message subject.
57
     *
58
     * @param string $value
59
     *
60
     * @return $this
61
     */
62 6
    public function subject($value)
63
    {
64 6
        if(is_array($value)){
65
            $this->setParameter('headings',$value);
66
        } else {
67 6
            $this->setParameter('headings',['en' => $value]);
68
        }
69 6
        return $this;
70
    }
71
72
    /**
73
     * Set the message url.
74
     *
75
     * @param string $value
76
     *
77
     * @return $this
78
     */
79 6
    public function url($value)
80
    {
81 6
       return $this->setUrl($value);
82
    }
83
84
85
    /**
86
     * Set additional data.
87
     *
88
     * @param string $key
89
     * @param mixed $value
90
     *
91
     * @return $this
92
     */
93 1
    public function setData(string $key, $value)
94
    {
95 1
        return $this->setParameter("data.{$key}", $value);
96
    }
97
98
    /**
99
     * Set additional parameters.
100
     *
101
     * @param string $key
102
     * @param mixed $value
103
     *
104
     * @return $this
105
     */
106 20
    public function setParameter(string $key, $value)
107
    {
108 20
        Arr::set($this->payload,$key,$value);
109 20
        return $this;
110
    }
111
112
113
114
    /**
115
     * @return array
116
     */
117 20
    public function toArray()
118
    {
119 20
        return $this->payload;
120
    }
121
}
122