Completed
Push — master ( b2c31d...142309 )
by Vitaliy
01:49
created

Alert::withLaunchImage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the AppleApnPush package
5
 *
6
 * (c) Vitaliy Zhuk <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code
10
 */
11
12
namespace Apple\ApnPush\Model;
13
14
/**
15
 * Value object for alert object
16
 */
17
class Alert
18
{
19
    /**
20
     * @var string
21
     */
22
    private $title = '';
23
24
    /**
25
     * @var Localized
26
     */
27
    private $titleLocalized;
28
29
    /**
30
     * @var string
31
     */
32
    private $body = '';
33
34
    /**
35
     * @var Localized
36
     */
37
    private $bodyLocalized;
38
39
    /**
40
     * @var Localized
41
     */
42
    private $actionLocalized;
43
44
    /**
45
     * @var string
46
     */
47
    private $launchImage = '';
48
49
    /**
50
     * Constructor.
51
     *
52
     * @param string $body
53
     * @param string $title
54
     */
55
    public function __construct(string $body = '', string $title = '')
56
    {
57
        $this->body = $body;
58
        $this->title = $title;
59
        $this->titleLocalized = new Localized('');
60
        $this->bodyLocalized = new Localized('');
61
        $this->actionLocalized = new Localized('');
62
    }
63
64
    /**
65
     * Set title
66
     *
67
     * @param string $title
68
     *
69
     * @return Alert
70
     */
71 View Code Duplication
    public function withTitle(string $title) : Alert
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
72
    {
73
        $cloned = clone $this;
74
75
        $this->titleLocalized = new Localized('');
76
        $cloned->title = $title;
77
78
        return $cloned;
79
    }
80
81
    /**
82
     * With localized title
83
     *
84
     * @param Localized $localized
85
     *
86
     * @return Alert
87
     */
88 View Code Duplication
    public function withLocalizedTitle(Localized $localized) : Alert
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
89
    {
90
        $cloned = clone $this;
91
92
        $cloned->title = '';
93
        $cloned->titleLocalized = $localized;
94
95
        return $cloned;
96
    }
97
98
    /**
99
     * Get title
100
     *
101
     * @return string
102
     */
103
    public function getTitle() : string
104
    {
105
        return $this->title;
106
    }
107
108
    /**
109
     * Get localized title
110
     *
111
     * @return Localized
112
     */
113
    public function getTitleLocalized() : Localized
114
    {
115
        return $this->titleLocalized;
116
    }
117
118
    /**
119
     * Set body
120
     *
121
     * @param string $body
122
     *
123
     * @return Alert
124
     */
125 View Code Duplication
    public function withBody(string $body) : Alert
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
126
    {
127
        $cloned = clone $this;
128
129
        $cloned->bodyLocalized = new Localized('');
130
        $cloned->body = $body;
131
132
        return $cloned;
133
    }
134
135
    /**
136
     * Set localized body
137
     *
138
     * @param Localized $localized
139
     *
140
     * @return Alert
141
     */
142 View Code Duplication
    public function withLocalizedBody(Localized $localized) : Alert
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
143
    {
144
        $cloned = clone $this;
145
146
        $cloned->body = '';
147
        $cloned->bodyLocalized = $localized;
148
149
        return $cloned;
150
    }
151
152
    /**
153
     * Get localized body
154
     *
155
     * @return Localized
156
     */
157
    public function getBodyLocalized() : Localized
158
    {
159
        return $this->bodyLocalized;
160
    }
161
162
    /**
163
     * Get body
164
     *
165
     * @return string
166
     */
167
    public function getBody() : string
168
    {
169
        return $this->body;
170
    }
171
172
    /**
173
     * With localized action
174
     *
175
     * @param Localized $localized
176
     *
177
     * @return Alert
178
     */
179
    public function withLocalizedAction(Localized $localized) : Alert
180
    {
181
        $cloned = clone $this;
182
183
        $cloned->actionLocalized = $localized;
184
185
        return $cloned;
186
    }
187
188
    /**
189
     * Get localized action
190
     *
191
     * @return Localized
192
     */
193
    public function getLocalizedAction() : Localized
194
    {
195
        return $this->actionLocalized;
196
    }
197
198
    /**
199
     * Add launch image
200
     *
201
     * @param string $launchImage
202
     *
203
     * @return Alert
204
     */
205
    public function withLaunchImage(string $launchImage) : Alert
206
    {
207
        $cloned = clone $this;
208
209
        $cloned->launchImage = $launchImage;
210
211
        return $cloned;
212
    }
213
214
    /**
215
     * Get launch image
216
     *
217
     * @return string
218
     */
219
    public function getLaunchImage() : string
220
    {
221
        return $this->launchImage;
222
    }
223
}
224