@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @see RGBAColor::ERROR_INVALID_COLOR_COMPONENT |
72 | 72 | * @see RGBAColor::ERROR_INVALID_PERCENTAGE_VALUE |
73 | 73 | */ |
74 | - public function __construct(float $red, float $green, float $blue, float $alpha=100) |
|
74 | + public function __construct(float $red, float $green, float $blue, float $alpha = 100) |
|
75 | 75 | { |
76 | 76 | $this->setColorPercentage(self::COMPONENT_RED, $red); |
77 | 77 | $this->setColorPercentage(self:: COMPONENT_GREEN, $green); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function setTransparency(float $transparency) : RGBAColor |
164 | 164 | { |
165 | - return $this->setColorPercentage(self::COMPONENT_ALPHA, 100-$transparency); |
|
165 | + return $this->setColorPercentage(self::COMPONENT_ALPHA, 100 - $transparency); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | { |
283 | 283 | $this->requireValidComponent($name); |
284 | 284 | |
285 | - if($percentage >= 0 && $percentage <= 100) |
|
285 | + if ($percentage >= 0 && $percentage <= 100) |
|
286 | 286 | { |
287 | 287 | $this->color[$name] = $percentage; |
288 | 288 | return $this; |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | { |
313 | 313 | $this->requireValidComponent($name); |
314 | 314 | |
315 | - if($value >= 0 && $value <= 255) |
|
315 | + if ($value >= 0 && $value <= 255) |
|
316 | 316 | { |
317 | 317 | // Convert the value to a percentage for the internal storage. |
318 | 318 | $percentage = $value * 100 / 255; |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | */ |
338 | 338 | private function requireValidComponent(string $name) : void |
339 | 339 | { |
340 | - if(in_array($name, self::COLOR_COMPONENTS)) |
|
340 | + if (in_array($name, self::COLOR_COMPONENTS)) |
|
341 | 341 | { |
342 | 342 | return; |
343 | 343 | } |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | { |
400 | 400 | $key = strval($offset); |
401 | 401 | |
402 | - if(isset($this->color[$key])) |
|
402 | + if (isset($this->color[$key])) |
|
403 | 403 | { |
404 | 404 | return $this->color[$key]; |
405 | 405 | } |
@@ -18,49 +18,49 @@ discard block |
||
18 | 18 | const CONTEXT_COMMAND_LINE = 'cli'; |
19 | 19 | const CONTEXT_WEB = 'web'; |
20 | 20 | |
21 | - /** |
|
22 | - * @var Throwable |
|
23 | - */ |
|
21 | + /** |
|
22 | + * @var Throwable |
|
23 | + */ |
|
24 | 24 | protected $exception; |
25 | 25 | |
26 | - /** |
|
27 | - * @var ConvertHelper_ThrowableInfo_Call[] |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var ConvertHelper_ThrowableInfo_Call[] |
|
28 | + */ |
|
29 | 29 | protected $calls = array(); |
30 | 30 | |
31 | - /** |
|
32 | - * @var integer |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var integer |
|
33 | + */ |
|
34 | 34 | protected $code; |
35 | 35 | |
36 | - /** |
|
37 | - * @var string |
|
38 | - */ |
|
36 | + /** |
|
37 | + * @var string |
|
38 | + */ |
|
39 | 39 | protected $message; |
40 | 40 | |
41 | - /** |
|
42 | - * @var integer |
|
43 | - */ |
|
41 | + /** |
|
42 | + * @var integer |
|
43 | + */ |
|
44 | 44 | protected $callsCount = 0; |
45 | 45 | |
46 | - /** |
|
47 | - * @var ConvertHelper_ThrowableInfo |
|
48 | - */ |
|
46 | + /** |
|
47 | + * @var ConvertHelper_ThrowableInfo |
|
48 | + */ |
|
49 | 49 | protected $previous; |
50 | 50 | |
51 | - /** |
|
52 | - * @var string |
|
53 | - */ |
|
51 | + /** |
|
52 | + * @var string |
|
53 | + */ |
|
54 | 54 | protected $referer = ''; |
55 | 55 | |
56 | - /** |
|
57 | - * @var DateTime |
|
58 | - */ |
|
56 | + /** |
|
57 | + * @var DateTime |
|
58 | + */ |
|
59 | 59 | protected $date; |
60 | 60 | |
61 | - /** |
|
62 | - * @var string |
|
63 | - */ |
|
61 | + /** |
|
62 | + * @var string |
|
63 | + */ |
|
64 | 64 | protected $context = self::CONTEXT_WEB; |
65 | 65 | |
66 | 66 | /** |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | return isset($this->previous); |
115 | 115 | } |
116 | 116 | |
117 | - /** |
|
118 | - * Retrieves the information on the previous exception. |
|
119 | - * |
|
120 | - * NOTE: Throws an exception if there is no previous |
|
121 | - * exception. Use hasPrevious() first to avoid this. |
|
122 | - * |
|
123 | - * @throws ConvertHelper_Exception |
|
124 | - * @return ConvertHelper_ThrowableInfo |
|
125 | - * @see ConvertHelper_ThrowableInfo::ERROR_NO_PREVIOUS_EXCEPTION |
|
126 | - */ |
|
117 | + /** |
|
118 | + * Retrieves the information on the previous exception. |
|
119 | + * |
|
120 | + * NOTE: Throws an exception if there is no previous |
|
121 | + * exception. Use hasPrevious() first to avoid this. |
|
122 | + * |
|
123 | + * @throws ConvertHelper_Exception |
|
124 | + * @return ConvertHelper_ThrowableInfo |
|
125 | + * @see ConvertHelper_ThrowableInfo::ERROR_NO_PREVIOUS_EXCEPTION |
|
126 | + */ |
|
127 | 127 | public function getPrevious() : ConvertHelper_ThrowableInfo |
128 | 128 | { |
129 | 129 | if(isset($this->previous)) { |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | return !empty($this->code); |
143 | 143 | } |
144 | 144 | |
145 | - /** |
|
146 | - * Improved textonly exception trace. |
|
147 | - */ |
|
145 | + /** |
|
146 | + * Improved textonly exception trace. |
|
147 | + */ |
|
148 | 148 | public function toString() : string |
149 | 149 | { |
150 | 150 | $calls = $this->getCalls(); |
@@ -172,73 +172,73 @@ discard block |
||
172 | 172 | return $string; |
173 | 173 | } |
174 | 174 | |
175 | - /** |
|
176 | - * Retrieves the URL of the page in which the exception |
|
177 | - * was thrown, if applicable: in CLI context, this will |
|
178 | - * return an empty string. |
|
179 | - * |
|
180 | - * @return string |
|
181 | - */ |
|
175 | + /** |
|
176 | + * Retrieves the URL of the page in which the exception |
|
177 | + * was thrown, if applicable: in CLI context, this will |
|
178 | + * return an empty string. |
|
179 | + * |
|
180 | + * @return string |
|
181 | + */ |
|
182 | 182 | public function getReferer() : string |
183 | 183 | { |
184 | 184 | return $this->referer; |
185 | 185 | } |
186 | 186 | |
187 | - /** |
|
188 | - * Whether the exception occurred in a command line context. |
|
189 | - * @return bool |
|
190 | - */ |
|
187 | + /** |
|
188 | + * Whether the exception occurred in a command line context. |
|
189 | + * @return bool |
|
190 | + */ |
|
191 | 191 | public function isCommandLine() : bool |
192 | 192 | { |
193 | 193 | return $this->getContext() === self::CONTEXT_COMMAND_LINE; |
194 | 194 | } |
195 | 195 | |
196 | - /** |
|
197 | - * Whether the exception occurred during an http request. |
|
198 | - * @return bool |
|
199 | - */ |
|
196 | + /** |
|
197 | + * Whether the exception occurred during an http request. |
|
198 | + * @return bool |
|
199 | + */ |
|
200 | 200 | public function isWebRequest() : bool |
201 | 201 | { |
202 | 202 | return $this->getContext() === self::CONTEXT_WEB; |
203 | 203 | } |
204 | 204 | |
205 | - /** |
|
206 | - * Retrieves the context identifier, i.e. if the exception |
|
207 | - * occurred in a command line context or regular web request. |
|
208 | - * |
|
209 | - * @return string |
|
210 | - * |
|
211 | - * @see ConvertHelper_ThrowableInfo::isCommandLine() |
|
212 | - * @see ConvertHelper_ThrowableInfo::isWebRequest() |
|
213 | - * @see ConvertHelper_ThrowableInfo::CONTEXT_COMMAND_LINE |
|
214 | - * @see ConvertHelper_ThrowableInfo::CONTEXT_WEB |
|
215 | - */ |
|
205 | + /** |
|
206 | + * Retrieves the context identifier, i.e. if the exception |
|
207 | + * occurred in a command line context or regular web request. |
|
208 | + * |
|
209 | + * @return string |
|
210 | + * |
|
211 | + * @see ConvertHelper_ThrowableInfo::isCommandLine() |
|
212 | + * @see ConvertHelper_ThrowableInfo::isWebRequest() |
|
213 | + * @see ConvertHelper_ThrowableInfo::CONTEXT_COMMAND_LINE |
|
214 | + * @see ConvertHelper_ThrowableInfo::CONTEXT_WEB |
|
215 | + */ |
|
216 | 216 | public function getContext() : string |
217 | 217 | { |
218 | 218 | return $this->context; |
219 | 219 | } |
220 | 220 | |
221 | - /** |
|
222 | - * Retrieves the date of the exception, and approximate time: |
|
223 | - * since exceptions do not store time, this is captured the |
|
224 | - * moment the ThrowableInfo is created. |
|
225 | - * |
|
226 | - * @return DateTime |
|
227 | - */ |
|
221 | + /** |
|
222 | + * Retrieves the date of the exception, and approximate time: |
|
223 | + * since exceptions do not store time, this is captured the |
|
224 | + * moment the ThrowableInfo is created. |
|
225 | + * |
|
226 | + * @return DateTime |
|
227 | + */ |
|
228 | 228 | public function getDate() : DateTime |
229 | 229 | { |
230 | 230 | return $this->date; |
231 | 231 | } |
232 | 232 | |
233 | - /** |
|
234 | - * Serializes all information on the exception to an |
|
235 | - * associative array. This can be saved (file, database, |
|
236 | - * session...), and later be restored into a throwable |
|
237 | - * info instance using the fromSerialized() method. |
|
238 | - * |
|
239 | - * @return array<string,mixed> |
|
240 | - * @see ConvertHelper_ThrowableInfo::fromSerialized() |
|
241 | - */ |
|
233 | + /** |
|
234 | + * Serializes all information on the exception to an |
|
235 | + * associative array. This can be saved (file, database, |
|
236 | + * session...), and later be restored into a throwable |
|
237 | + * info instance using the fromSerialized() method. |
|
238 | + * |
|
239 | + * @return array<string,mixed> |
|
240 | + * @see ConvertHelper_ThrowableInfo::fromSerialized() |
|
241 | + */ |
|
242 | 242 | public function serialize() : array |
243 | 243 | { |
244 | 244 | $result = array( |
@@ -265,24 +265,24 @@ discard block |
||
265 | 265 | return $result; |
266 | 266 | } |
267 | 267 | |
268 | - /** |
|
269 | - * Sets the maximum folder depth to show in the |
|
270 | - * file paths, to avoid them being too long. |
|
271 | - * |
|
272 | - * @param int $depth |
|
273 | - * @return ConvertHelper_ThrowableInfo |
|
274 | - */ |
|
268 | + /** |
|
269 | + * Sets the maximum folder depth to show in the |
|
270 | + * file paths, to avoid them being too long. |
|
271 | + * |
|
272 | + * @param int $depth |
|
273 | + * @return ConvertHelper_ThrowableInfo |
|
274 | + */ |
|
275 | 275 | public function setFolderDepth(int $depth) : ConvertHelper_ThrowableInfo |
276 | 276 | { |
277 | 277 | return $this->setOption('folder-depth', $depth); |
278 | 278 | } |
279 | 279 | |
280 | - /** |
|
281 | - * Retrieves the current folder depth option value. |
|
282 | - * |
|
283 | - * @return int |
|
284 | - * @see ConvertHelper_ThrowableInfo::setFolderDepth() |
|
285 | - */ |
|
280 | + /** |
|
281 | + * Retrieves the current folder depth option value. |
|
282 | + * |
|
283 | + * @return int |
|
284 | + * @see ConvertHelper_ThrowableInfo::setFolderDepth() |
|
285 | + */ |
|
286 | 286 | public function getFolderDepth() : int |
287 | 287 | { |
288 | 288 | $depth = $this->getOption('folder-depth'); |
@@ -293,13 +293,13 @@ discard block |
||
293 | 293 | return 2; |
294 | 294 | } |
295 | 295 | |
296 | - /** |
|
297 | - * Retrieves all function calls that led to the error, |
|
298 | - * ordered from latest to earliest (the first one in |
|
299 | - * the stack is actually the last call). |
|
300 | - * |
|
301 | - * @return ConvertHelper_ThrowableInfo_Call[] |
|
302 | - */ |
|
296 | + /** |
|
297 | + * Retrieves all function calls that led to the error, |
|
298 | + * ordered from latest to earliest (the first one in |
|
299 | + * the stack is actually the last call). |
|
300 | + * |
|
301 | + * @return ConvertHelper_ThrowableInfo_Call[] |
|
302 | + */ |
|
303 | 303 | public function getCalls() |
304 | 304 | { |
305 | 305 | return $this->calls; |
@@ -315,10 +315,10 @@ discard block |
||
315 | 315 | return $this->calls[0]; |
316 | 316 | } |
317 | 317 | |
318 | - /** |
|
319 | - * Returns the amount of function and method calls in the stack trace. |
|
320 | - * @return int |
|
321 | - */ |
|
318 | + /** |
|
319 | + * Returns the amount of function and method calls in the stack trace. |
|
320 | + * @return int |
|
321 | + */ |
|
322 | 322 | public function countCalls() : int |
323 | 323 | { |
324 | 324 | return $this->callsCount; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | protected function __construct($subject) |
70 | 70 | { |
71 | - if(is_array($subject)) |
|
71 | + if (is_array($subject)) |
|
72 | 72 | { |
73 | 73 | $this->parseSerialized($subject); |
74 | 74 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function getPrevious() : ConvertHelper_ThrowableInfo |
128 | 128 | { |
129 | - if(isset($this->previous)) { |
|
129 | + if (isset($this->previous)) { |
|
130 | 130 | return $this->previous; |
131 | 131 | } |
132 | 132 | |
@@ -151,18 +151,18 @@ discard block |
||
151 | 151 | |
152 | 152 | $string = 'Exception'; |
153 | 153 | |
154 | - if($this->hasCode()) { |
|
154 | + if ($this->hasCode()) { |
|
155 | 155 | $string .= ' #'.$this->code; |
156 | 156 | } |
157 | 157 | |
158 | 158 | $string .= ': '.$this->getMessage().PHP_EOL; |
159 | 159 | |
160 | - foreach($calls as $call) |
|
160 | + foreach ($calls as $call) |
|
161 | 161 | { |
162 | 162 | $string .= $call->toString().PHP_EOL; |
163 | 163 | } |
164 | 164 | |
165 | - if($this->hasPrevious()) |
|
165 | + if ($this->hasPrevious()) |
|
166 | 166 | { |
167 | 167 | $string .= PHP_EOL.PHP_EOL. |
168 | 168 | 'Previous error:'.PHP_EOL.PHP_EOL. |
@@ -253,11 +253,11 @@ discard block |
||
253 | 253 | 'previous' => null, |
254 | 254 | ); |
255 | 255 | |
256 | - if($this->hasPrevious()) { |
|
257 | - $result['previous'] = $this->previous->serialize(); |
|
256 | + if ($this->hasPrevious()) { |
|
257 | + $result['previous'] = $this->previous->serialize(); |
|
258 | 258 | } |
259 | 259 | |
260 | - foreach($this->calls as $call) |
|
260 | + foreach ($this->calls as $call) |
|
261 | 261 | { |
262 | 262 | $result['calls'][] = $call->serialize(); |
263 | 263 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | public function getFolderDepth() : int |
287 | 287 | { |
288 | 288 | $depth = $this->getOption('folder-depth'); |
289 | - if(!empty($depth)) { |
|
289 | + if (!empty($depth)) { |
|
290 | 290 | return $depth; |
291 | 291 | } |
292 | 292 | |
@@ -340,12 +340,12 @@ discard block |
||
340 | 340 | |
341 | 341 | $this->setOptions($serialized['options']); |
342 | 342 | |
343 | - if(!empty($serialized['previous'])) |
|
343 | + if (!empty($serialized['previous'])) |
|
344 | 344 | { |
345 | 345 | $this->previous = ConvertHelper_ThrowableInfo::fromSerialized($serialized['previous']); |
346 | 346 | } |
347 | 347 | |
348 | - foreach($serialized['calls'] as $def) |
|
348 | + foreach ($serialized['calls'] as $def) |
|
349 | 349 | { |
350 | 350 | $this->calls[] = ConvertHelper_ThrowableInfo_Call::fromSerialized($this, $def); |
351 | 351 | } |
@@ -357,16 +357,16 @@ discard block |
||
357 | 357 | $this->message = $e->getMessage(); |
358 | 358 | $this->code = $e->getCode(); |
359 | 359 | |
360 | - if(!isset($_REQUEST['REQUEST_URI'])) { |
|
360 | + if (!isset($_REQUEST['REQUEST_URI'])) { |
|
361 | 361 | $this->context = self::CONTEXT_COMMAND_LINE; |
362 | 362 | } |
363 | 363 | |
364 | 364 | $previous = $e->getPrevious(); |
365 | - if(!empty($previous)) { |
|
365 | + if (!empty($previous)) { |
|
366 | 366 | $this->previous = ConvertHelper::throwable2info($previous); |
367 | 367 | } |
368 | 368 | |
369 | - if(isset($_SERVER['REQUEST_URI'])) { |
|
369 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
370 | 370 | $this->referer = $_SERVER['REQUEST_URI']; |
371 | 371 | } |
372 | 372 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | |
381 | 381 | $idx = 1; |
382 | 382 | |
383 | - foreach($trace as $entry) |
|
383 | + foreach ($trace as $entry) |
|
384 | 384 | { |
385 | 385 | $this->calls[] = ConvertHelper_ThrowableInfo_Call::fromTrace($this, $idx, $entry); |
386 | 386 | |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | * @return string |
416 | 416 | * @throws ConvertHelper_Exception |
417 | 417 | */ |
418 | - public function renderErrorMessage(bool $withDeveloperInfo=false) : string |
|
418 | + public function renderErrorMessage(bool $withDeveloperInfo = false) : string |
|
419 | 419 | { |
420 | 420 | $finalCall = $this->getFinalCall(); |
421 | 421 | |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | ->t('Message:') |
428 | 428 | ->add($this->getMessage()); |
429 | 429 | |
430 | - if($withDeveloperInfo) |
|
430 | + if ($withDeveloperInfo) |
|
431 | 431 | { |
432 | 432 | $message |
433 | 433 | ->eol() |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | ->add($finalCall->toString()); |
436 | 436 | } |
437 | 437 | |
438 | - if($withDeveloperInfo && $this->hasDetails()) |
|
438 | + if ($withDeveloperInfo && $this->hasDetails()) |
|
439 | 439 | { |
440 | 440 | $message |
441 | 441 | ->t('Developer details:') |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | |
446 | 446 | $previous = $this->getPrevious(); |
447 | 447 | |
448 | - if($previous !== null) |
|
448 | + if ($previous !== null) |
|
449 | 449 | { |
450 | 450 | $message |
451 | 451 | ->eol() |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | |
461 | 461 | public function getDetails() : string |
462 | 462 | { |
463 | - if($this->exception instanceof BaseException) |
|
463 | + if ($this->exception instanceof BaseException) |
|
464 | 464 | { |
465 | 465 | return $this->exception->getDetails(); |
466 | 466 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @param string $message Should not contain a date, just the system specific info. |
145 | 145 | * @return OperationResult |
146 | 146 | */ |
147 | - public function makeSuccess(string $message, int $code=0) : OperationResult |
|
147 | + public function makeSuccess(string $message, int $code = 0) : OperationResult |
|
148 | 148 | { |
149 | 149 | return $this->setMessage(self::TYPE_SUCCESS, $message, $code, true); |
150 | 150 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param string $message Should be as detailed as possible. |
156 | 156 | * @return OperationResult |
157 | 157 | */ |
158 | - public function makeError(string $message, int $code=0) : OperationResult |
|
158 | + public function makeError(string $message, int $code = 0) : OperationResult |
|
159 | 159 | { |
160 | 160 | return $this->setMessage(self::TYPE_ERROR, $message, $code, false); |
161 | 161 | } |
@@ -235,11 +235,11 @@ discard block |
||
235 | 235 | return $this->code; |
236 | 236 | } |
237 | 237 | |
238 | - public function getMessage(string $type='') : string |
|
238 | + public function getMessage(string $type = '') : string |
|
239 | 239 | { |
240 | - if(!empty($type)) |
|
240 | + if (!empty($type)) |
|
241 | 241 | { |
242 | - if($this->type === $type) |
|
242 | + if ($this->type === $type) |
|
243 | 243 | { |
244 | 244 | return $this->message; |
245 | 245 | } |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @throws ConvertHelper_Exception |
265 | 265 | */ |
266 | - public function makeException(Throwable $e, int $code=0, bool $withDeveloperInfo=false) : OperationResult |
|
266 | + public function makeException(Throwable $e, int $code = 0, bool $withDeveloperInfo = false) : OperationResult |
|
267 | 267 | { |
268 | 268 | $info = parseThrowable($e); |
269 | 269 | |
270 | - if($code === 0) |
|
270 | + if ($code === 0) |
|
271 | 271 | { |
272 | 272 | $code = $info->getCode(); |
273 | 273 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public static function getPresetsManager() : RGBAColor_PresetsManager |
40 | 40 | { |
41 | - if(!isset(self::$presets)) |
|
41 | + if (!isset(self::$presets)) |
|
42 | 42 | { |
43 | 43 | self::$presets = new RGBAColor_PresetsManager(); |
44 | 44 | } |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public static function createAuto($subject) : RGBAColor |
62 | 62 | { |
63 | - if($subject instanceof RGBAColor) |
|
63 | + if ($subject instanceof RGBAColor) |
|
64 | 64 | { |
65 | 65 | return $subject; |
66 | 66 | } |
67 | 67 | |
68 | - if(is_array($subject)) |
|
68 | + if (is_array($subject)) |
|
69 | 69 | { |
70 | - if(RGBAColor_Converter::isColorArray($subject)) |
|
70 | + if (RGBAColor_Converter::isColorArray($subject)) |
|
71 | 71 | { |
72 | 72 | return self::createFromColor($subject); |
73 | 73 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | return self::createFromIndexedColor($subject); |
76 | 76 | } |
77 | 77 | |
78 | - if(is_string($subject)) |
|
78 | + if (is_string($subject)) |
|
79 | 79 | { |
80 | 80 | return self::createFromHEX($subject); |
81 | 81 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public static function createFromColor(array $color) : RGBAColor |
118 | 118 | { |
119 | - if(!isset($color[RGBAColor::COMPONENT_ALPHA])) |
|
119 | + if (!isset($color[RGBAColor::COMPONENT_ALPHA])) |
|
120 | 120 | { |
121 | 121 | $color[RGBAColor::COMPONENT_ALPHA] = 255; |
122 | 122 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $values = array_values($color); |
164 | 164 | $amountKeys = count($values); |
165 | 165 | |
166 | - if($amountKeys === 3) |
|
166 | + if ($amountKeys === 3) |
|
167 | 167 | { |
168 | 168 | return self::createFromColor(array( |
169 | 169 | RGBAColor::COMPONENT_RED => $color[0], |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | )); |
173 | 173 | } |
174 | 174 | |
175 | - if($amountKeys === 4) |
|
175 | + if ($amountKeys === 4) |
|
176 | 176 | { |
177 | 177 | return self::createFromColor(array( |
178 | 178 | RGBAColor::COMPONENT_RED => $color[0], |
@@ -39,9 +39,9 @@ |
||
39 | 39 | { |
40 | 40 | $parts = array(RGBAColor::COMPONENT_RED, RGBAColor::COMPONENT_GREEN, RGBAColor::COMPONENT_BLUE); |
41 | 41 | |
42 | - foreach($parts as $part) |
|
42 | + foreach ($parts as $part) |
|
43 | 43 | { |
44 | - if($sourceColor->getColorValue($part) !== $targetColor->getColorValue($part)) |
|
44 | + if ($sourceColor->getColorValue($part) !== $targetColor->getColorValue($part)) |
|
45 | 45 | { |
46 | 46 | return false; |
47 | 47 | } |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | */ |
61 | 61 | private function init() : void |
62 | 62 | { |
63 | - if(self::$initialized === true) |
|
63 | + if (self::$initialized === true) |
|
64 | 64 | { |
65 | 65 | return; |
66 | 66 | } |
67 | 67 | |
68 | 68 | $this |
69 | 69 | ->registerGlobalPreset(self::COLOR_WHITE, 255, 255, 255, 255) |
70 | - ->registerGlobalPreset(self::COLOR_BLACK, 0,0,0, 255) |
|
70 | + ->registerGlobalPreset(self::COLOR_BLACK, 0, 0, 0, 255) |
|
71 | 71 | ->registerGlobalPreset(self::COLOR_TRANSPARENT, 0, 0, 0, 0); |
72 | 72 | } |
73 | 73 | |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function getPreset(string $name) : array |
82 | 82 | { |
83 | - if(isset($this->customPresets[$name])) |
|
83 | + if (isset($this->customPresets[$name])) |
|
84 | 84 | { |
85 | 85 | return $this->customPresets[$name]; |
86 | 86 | } |
87 | 87 | |
88 | - if(isset(self::$globalPresets[$name])) |
|
88 | + if (isset(self::$globalPresets[$name])) |
|
89 | 89 | { |
90 | 90 | return self::$globalPresets[$name]; |
91 | 91 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | { |
114 | 114 | $this->requireNotGlobal($name); |
115 | 115 | |
116 | - if(!isset(self::$globalPresets[$name])) |
|
116 | + if (!isset(self::$globalPresets[$name])) |
|
117 | 117 | { |
118 | 118 | self::$globalPresets[$name] = array( |
119 | 119 | RGBAColor::COMPONENT_RED => $red, |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | ); |
136 | 136 | } |
137 | 137 | |
138 | - public function registerPreset(string $name, int $red, int $green, int $blue, int $alpha=255) : RGBAColor_PresetsManager |
|
138 | + public function registerPreset(string $name, int $red, int $green, int $blue, int $alpha = 255) : RGBAColor_PresetsManager |
|
139 | 139 | { |
140 | 140 | $this->requireNotGlobal($name); |
141 | 141 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | private function requireNotGlobal(string $name) : void |
153 | 153 | { |
154 | - if(!isset(self::$globalPresets[$name])) |
|
154 | + if (!isset(self::$globalPresets[$name])) |
|
155 | 155 | { |
156 | 156 | return; |
157 | 157 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public static function requireValidColorArray(array $color) : void |
50 | 50 | { |
51 | - if(self::isColorArray($color)) |
|
51 | + if (self::isColorArray($color)) |
|
52 | 52 | { |
53 | 53 | return; |
54 | 54 | } |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | RGBAColor::COMPONENT_BLUE |
81 | 81 | ); |
82 | 82 | |
83 | - foreach($keys as $key) |
|
83 | + foreach ($keys as $key) |
|
84 | 84 | { |
85 | - if(!isset($color[$key])) |
|
85 | + if (!isset($color[$key])) |
|
86 | 86 | { |
87 | 87 | return false; |
88 | 88 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | self::int2hex($color[RGBAColor::COMPONENT_GREEN]). |
105 | 105 | self::int2hex($color[RGBAColor::COMPONENT_BLUE]); |
106 | 106 | |
107 | - if(isset($color[RGBAColor::COMPONENT_ALPHA]) && $color[RGBAColor::COMPONENT_ALPHA] < 255) |
|
107 | + if (isset($color[RGBAColor::COMPONENT_ALPHA]) && $color[RGBAColor::COMPONENT_ALPHA] < 255) |
|
108 | 108 | { |
109 | 109 | $hex .= self::int2hex($color[RGBAColor::COMPONENT_ALPHA]); |
110 | 110 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | private static function int2hex(int $int) : string |
125 | 125 | { |
126 | 126 | $str = dechex($int); |
127 | - if(strlen($str) === 1) |
|
127 | + if (strlen($str) === 1) |
|
128 | 128 | { |
129 | 129 | $str = $str.$str; |
130 | 130 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public static function color2readable(RGBAColor $color) : string |
145 | 145 | { |
146 | - if($color->hasTransparency()) |
|
146 | + if ($color->hasTransparency()) |
|
147 | 147 | { |
148 | 148 | return sprintf( |
149 | 149 | 'RGBA(%s %s %s %s)', |
@@ -207,11 +207,11 @@ discard block |
||
207 | 207 | $hex = strtoupper($hex); |
208 | 208 | $length = strlen($hex); |
209 | 209 | |
210 | - if($length === 3) |
|
210 | + if ($length === 3) |
|
211 | 211 | { |
212 | 212 | return self::parseHEX3($hex); |
213 | 213 | } |
214 | - else if($length === 6) |
|
214 | + else if ($length === 6) |
|
215 | 215 | { |
216 | 216 | return self::parseHEX6($hex); |
217 | 217 | } |
@@ -210,12 +210,10 @@ |
||
210 | 210 | if($length === 3) |
211 | 211 | { |
212 | 212 | return self::parseHEX3($hex); |
213 | - } |
|
214 | - else if($length === 6) |
|
213 | + } else if($length === 6) |
|
215 | 214 | { |
216 | 215 | return self::parseHEX6($hex); |
217 | - } |
|
218 | - else if ($length === 8) |
|
216 | + } else if ($length === 8) |
|
219 | 217 | { |
220 | 218 | return self::parseHEX8($hex); |
221 | 219 | } |