1 | <?php |
||
2 | |||
3 | namespace Coinpaprika\Model; |
||
4 | |||
5 | use Coinpaprika\Model\Ico\Condition; |
||
6 | |||
7 | /** |
||
8 | * Class Ico |
||
9 | * |
||
10 | * @package \Coinpaprika\Model |
||
11 | * |
||
12 | * @author Krzysztof Przybyszewski <[email protected]> |
||
13 | */ |
||
14 | class Ico |
||
15 | { |
||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private $id; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $name; |
||
25 | |||
26 | /** |
||
27 | * @var string|null |
||
28 | */ |
||
29 | private $symbol; |
||
30 | |||
31 | /** |
||
32 | * @var bool |
||
33 | */ |
||
34 | private $onMarket; |
||
35 | |||
36 | /** |
||
37 | * @var bool |
||
38 | */ |
||
39 | private $suspended; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | private $status; |
||
45 | |||
46 | /** |
||
47 | * @var int|null |
||
48 | */ |
||
49 | private $goal; |
||
50 | |||
51 | /** |
||
52 | * @var int|null |
||
53 | */ |
||
54 | private $received; |
||
55 | |||
56 | /** |
||
57 | * @var array|Condition[]|null |
||
58 | */ |
||
59 | private $conditions; |
||
60 | |||
61 | /** |
||
62 | * @var \DateTime|null |
||
63 | */ |
||
64 | private $startDate; |
||
65 | |||
66 | /** |
||
67 | * @var \DateTime|null |
||
68 | */ |
||
69 | private $endDate; |
||
70 | |||
71 | /** |
||
72 | * @var array|string[] |
||
73 | */ |
||
74 | private $tagIds; |
||
75 | |||
76 | /** |
||
77 | * @return string |
||
78 | */ |
||
79 | 1 | public function getId(): string |
|
80 | { |
||
81 | 1 | return $this->id; |
|
82 | } |
||
83 | |||
84 | /** |
||
85 | * @param string $id |
||
86 | */ |
||
87 | 1 | public function setId(string $id): void |
|
88 | { |
||
89 | 1 | $this->id = $id; |
|
90 | 1 | } |
|
91 | |||
92 | /** |
||
93 | * @return string |
||
94 | */ |
||
95 | 1 | public function getName(): string |
|
96 | { |
||
97 | 1 | return $this->name; |
|
98 | } |
||
99 | |||
100 | /** |
||
101 | * @param string $name |
||
102 | */ |
||
103 | 1 | public function setName(string $name): void |
|
104 | { |
||
105 | 1 | $this->name = $name; |
|
106 | 1 | } |
|
107 | |||
108 | /** |
||
109 | * @return string|null |
||
110 | */ |
||
111 | 1 | public function getSymbol(): ?string |
|
112 | { |
||
113 | 1 | return $this->symbol; |
|
114 | } |
||
115 | |||
116 | /** |
||
117 | * @param string|null $symbol |
||
118 | */ |
||
119 | 1 | public function setSymbol(?string $symbol): void |
|
120 | { |
||
121 | 1 | $this->symbol = $symbol; |
|
122 | 1 | } |
|
123 | |||
124 | /** |
||
125 | * @return bool |
||
126 | */ |
||
127 | 1 | public function isOnMarket(): bool |
|
128 | { |
||
129 | 1 | return $this->onMarket; |
|
130 | } |
||
131 | |||
132 | /** |
||
133 | * @param bool $onMarket |
||
134 | */ |
||
135 | 1 | public function setOnMarket(bool $onMarket): void |
|
136 | { |
||
137 | 1 | $this->onMarket = $onMarket; |
|
138 | 1 | } |
|
139 | |||
140 | /** |
||
141 | * @return string |
||
142 | */ |
||
143 | 1 | public function getStatus(): string |
|
144 | { |
||
145 | 1 | return $this->status; |
|
146 | } |
||
147 | |||
148 | /** |
||
149 | * @param string $status |
||
150 | */ |
||
151 | 1 | public function setStatus(string $status): void |
|
152 | { |
||
153 | 1 | $this->status = $status; |
|
154 | 1 | } |
|
155 | |||
156 | /** |
||
157 | * @return int|null |
||
158 | */ |
||
159 | 1 | public function getGoal(): ?int |
|
160 | { |
||
161 | 1 | return $this->goal; |
|
162 | } |
||
163 | |||
164 | /** |
||
165 | * @param int|null $goal |
||
166 | */ |
||
167 | 1 | public function setGoal(?int $goal): void |
|
168 | { |
||
169 | 1 | $this->goal = $goal; |
|
170 | 1 | } |
|
171 | |||
172 | /** |
||
173 | * @return int|null |
||
174 | */ |
||
175 | 1 | public function getReceived(): ?int |
|
176 | { |
||
177 | 1 | return $this->received; |
|
178 | } |
||
179 | |||
180 | /** |
||
181 | * @param int|null $received |
||
182 | */ |
||
183 | 1 | public function setReceived(?int $received): void |
|
184 | { |
||
185 | 1 | $this->received = $received; |
|
186 | 1 | } |
|
187 | |||
188 | /** |
||
189 | * @return array|Condition[] |
||
190 | */ |
||
191 | 1 | public function getConditions(): array |
|
192 | { |
||
193 | 1 | if (null === $this->conditions) { |
|
194 | return []; |
||
195 | } |
||
196 | |||
197 | 1 | return $this->conditions; |
|
198 | } |
||
199 | |||
200 | /** |
||
201 | * @param array|Condition[]|null $conditions |
||
202 | */ |
||
203 | 1 | public function setConditions(?array $conditions): void |
|
204 | { |
||
205 | 1 | $this->conditions = $conditions; |
|
206 | 1 | } |
|
207 | |||
208 | /** |
||
209 | * @return \DateTime|null |
||
210 | */ |
||
211 | 1 | public function getStartDate(): ?\DateTime |
|
212 | { |
||
213 | 1 | return $this->startDate; |
|
214 | } |
||
215 | |||
216 | /** |
||
217 | * @param \DateTime|null $startDate |
||
218 | */ |
||
219 | 1 | public function setStartDate(?\DateTime $startDate): void |
|
220 | { |
||
221 | 1 | $this->startDate = $startDate; |
|
222 | 1 | } |
|
223 | |||
224 | /** |
||
225 | * @return \DateTime|null |
||
226 | */ |
||
227 | 1 | public function getEndDate(): ?\DateTime |
|
228 | { |
||
229 | 1 | return $this->endDate; |
|
230 | } |
||
231 | |||
232 | /** |
||
233 | * @param \DateTime|null $endDate |
||
234 | */ |
||
235 | 1 | public function setEndDate(?\DateTime $endDate): void |
|
236 | { |
||
237 | 1 | $this->endDate = $endDate; |
|
238 | 1 | } |
|
239 | |||
240 | /** |
||
241 | * Returns percentage value of received to goal money |
||
242 | * |
||
243 | * @return int |
||
244 | */ |
||
245 | public function getReceivedPercent(): int |
||
246 | { |
||
247 | if (!$this->getGoal()) { |
||
0 ignored issues
–
show
|
|||
248 | return 0; |
||
249 | } |
||
250 | |||
251 | return (int) $this->getReceived() * 100 / $this->getGoal(); |
||
252 | } |
||
253 | |||
254 | /** |
||
255 | * @return bool |
||
256 | */ |
||
257 | 1 | public function isSuspended(): bool |
|
258 | { |
||
259 | 1 | return $this->suspended; |
|
260 | } |
||
261 | |||
262 | /** |
||
263 | * @param bool $suspended |
||
264 | */ |
||
265 | 1 | public function setSuspended(bool $suspended): void |
|
266 | { |
||
267 | 1 | $this->suspended = $suspended; |
|
268 | 1 | } |
|
269 | |||
270 | /** |
||
271 | * @return array |
||
272 | */ |
||
273 | 1 | public function getTagIds(): array |
|
274 | { |
||
275 | 1 | if (null === $this->tagIds) { |
|
276 | return []; |
||
277 | } |
||
278 | |||
279 | 1 | return $this->tagIds; |
|
280 | } |
||
281 | |||
282 | /** |
||
283 | * @param array $tagIds |
||
284 | */ |
||
285 | 1 | public function setTagIds(array $tagIds): void |
|
286 | { |
||
287 | 1 | $this->tagIds = $tagIds; |
|
288 | 1 | } |
|
289 | } |
||
290 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: