@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | * @return Controls\Security\Csrf |
| 374 | 374 | * @codeCoverageIgnore link adapter remote resource |
| 375 | 375 | */ |
| 376 | - public function addCsrf(string $alias, ArrayAccess &$cookie, string $errorMessage, $attributes = []) |
|
| 376 | + public function addCsrf(string $alias, ArrayAccess & $cookie, string $errorMessage, $attributes = []) |
|
| 377 | 377 | { |
| 378 | 378 | $csrf = new Controls\Security\Csrf(); |
| 379 | 379 | $csrf->setHidden($alias, $cookie, $errorMessage)->addAttributes($attributes); |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | * @param array<string, string|array<string>>|string $attributes |
| 390 | 390 | * @return Controls\Security\MultiSend |
| 391 | 391 | */ |
| 392 | - public function addMultiSend(string $alias, ArrayAccess &$cookie, string $errorMessage, $attributes = []) |
|
| 392 | + public function addMultiSend(string $alias, ArrayAccess & $cookie, string $errorMessage, $attributes = []) |
|
| 393 | 393 | { |
| 394 | 394 | $csrf = new Controls\Security\MultiSend(); |
| 395 | 395 | $csrf->setHidden($alias, $cookie, $errorMessage)->addAttributes($attributes); |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | * @param string $errorMessage |
| 418 | 418 | * @return Controls\Security\Captcha\Text |
| 419 | 419 | */ |
| 420 | - public function addCaptchaText(string $alias, ArrayAccess &$session, string $errorMessage = 'Captcha mismatch') |
|
| 420 | + public function addCaptchaText(string $alias, ArrayAccess & $session, string $errorMessage = 'Captcha mismatch') |
|
| 421 | 421 | { |
| 422 | 422 | $captcha = new Controls\Security\Captcha\Text(); |
| 423 | 423 | $captcha->set($alias, $session, $errorMessage); |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | * @param string $errorMessage |
| 433 | 433 | * @return Controls\Security\Captcha\Numerical |
| 434 | 434 | */ |
| 435 | - public function addCaptchaMath(string $alias, ArrayAccess &$session, string $errorMessage = 'Captcha mismatch') |
|
| 435 | + public function addCaptchaMath(string $alias, ArrayAccess & $session, string $errorMessage = 'Captcha mismatch') |
|
| 436 | 436 | { |
| 437 | 437 | $captcha = new Controls\Security\Captcha\Numerical(); |
| 438 | 438 | $captcha->set($alias, $session, $errorMessage); |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | * @param string $errorMessage |
| 448 | 448 | * @return Controls\Security\Captcha\ColourfulText |
| 449 | 449 | */ |
| 450 | - public function addCaptchaColour(string $alias, ArrayAccess &$session, string $errorMessage = 'Captcha mismatch') |
|
| 450 | + public function addCaptchaColour(string $alias, ArrayAccess & $session, string $errorMessage = 'Captcha mismatch') |
|
| 451 | 451 | { |
| 452 | 452 | $captcha = new Controls\Security\Captcha\ColourfulText(); |
| 453 | 453 | $captcha->set($alias, $session, $errorMessage); |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public function isStored(): bool |
| 27 | 27 | { |
| 28 | - return $this->storage ? $this->storage->isStored() : false ; |
|
| 28 | + return $this->storage ? $this->storage->isStored() : false; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | public function getValue(string $key) |
| 140 | 140 | { |
| 141 | 141 | $control = $this->getControl($key); |
| 142 | - return $control ? $control->getValue() : null ; |
|
| 142 | + return $control ? $control->getValue() : null; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -234,11 +234,11 @@ discard block |
||
| 234 | 234 | $result = []; |
| 235 | 235 | foreach ($adapter as $key => $entry) { |
| 236 | 236 | $result[strval($key)] = is_object($entry) && !$raw |
| 237 | - ? ( method_exists($entry, 'getValue') |
|
| 237 | + ? (method_exists($entry, 'getValue') |
|
| 238 | 238 | ? $entry->getValue() |
| 239 | 239 | : strval($entry) |
| 240 | 240 | ) |
| 241 | - : $entry ; |
|
| 241 | + : $entry; |
|
| 242 | 242 | } |
| 243 | 243 | return $result; |
| 244 | 244 | } |
@@ -220,8 +220,12 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | public function setSentValues(): void |
| 222 | 222 | { |
| 223 | - if ($this->files) $this->setValues($this->setValuesToFill($this->files, true)); |
|
| 224 | - if ($this->entries) $this->setValues($this->setValuesToFill($this->entries)); |
|
| 223 | + if ($this->files) { |
|
| 224 | + $this->setValues($this->setValuesToFill($this->files, true)); |
|
| 225 | + } |
|
| 226 | + if ($this->entries) { |
|
| 227 | + $this->setValues($this->setValuesToFill($this->entries)); |
|
| 228 | + } |
|
| 225 | 229 | } |
| 226 | 230 | |
| 227 | 231 | /** |
@@ -276,7 +280,10 @@ discard block |
||
| 276 | 280 | */ |
| 277 | 281 | public function store(): void |
| 278 | 282 | { |
| 279 | - if ($this->storage) $this->storage->store($this->getValues(), 86400); # day |
|
| 283 | + if ($this->storage) { |
|
| 284 | + $this->storage->store($this->getValues(), 86400); |
|
| 285 | + } |
|
| 286 | + # day |
|
| 280 | 287 | } |
| 281 | 288 | |
| 282 | 289 | /** |
@@ -285,7 +292,9 @@ discard block |
||
| 285 | 292 | */ |
| 286 | 293 | public function loadStored(): void |
| 287 | 294 | { |
| 288 | - if ($this->storage) $this->setValues($this->storage->load()); |
|
| 295 | + if ($this->storage) { |
|
| 296 | + $this->setValues($this->storage->load()); |
|
| 297 | + } |
|
| 289 | 298 | } |
| 290 | 299 | |
| 291 | 300 | /** |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class Numerical extends AGraphical |
| 16 | 16 | { |
| 17 | - public function set(string $alias, ArrayAccess &$session, string $errorMessage, string $font = '/usr/share/fonts/truetype/freefont/FreeMono.ttf'): AGraphical |
|
| 17 | + public function set(string $alias, ArrayAccess & $session, string $errorMessage, string $font = '/usr/share/fonts/truetype/freefont/FreeMono.ttf'): AGraphical |
|
| 18 | 18 | { |
| 19 | 19 | $this->font = $font; |
| 20 | 20 | |
@@ -51,6 +51,6 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | public function renderInput($attributes = null): string |
| 53 | 53 | { |
| 54 | - return parent::renderLabel() . ' '. parent::renderInput($attributes); |
|
| 54 | + return parent::renderLabel() . ' ' . parent::renderInput($attributes); |
|
| 55 | 55 | } |
| 56 | 56 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | class ColourfulText extends AGraphical |
| 17 | 17 | { |
| 18 | - public function set(string $alias, ArrayAccess &$session, string $errorMessage, string $font = '/usr/share/fonts/truetype/freefont/freesans.ttf'): AGraphical |
|
| 18 | + public function set(string $alias, ArrayAccess & $session, string $errorMessage, string $font = '/usr/share/fonts/truetype/freefont/freesans.ttf'): AGraphical |
|
| 19 | 19 | { |
| 20 | 20 | $this->font = $font; |
| 21 | 21 | $text = $this->generateRandomString(6); |
@@ -75,18 +75,18 @@ discard block |
||
| 75 | 75 | # height of the ellipse are random numbers between 0 and 3, for obtaining ellipses with dot aspect. |
| 76 | 76 | # generate random dots |
| 77 | 77 | for ($i = 0; $i < ($width * $height); $i++) { |
| 78 | - imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0,3), mt_rand(0,3), $dots_color); |
|
| 78 | + imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, 3), mt_rand(0, 3), $dots_color); |
|
| 79 | 79 | } |
| 80 | 80 | # To generate random lines using the imageline PHP function, randomly generate the lengths and the |
| 81 | 81 | # coordinates of the lines as in the below code: |
| 82 | 82 | # generate random lines |
| 83 | - for ($i=0; $i < ($width + $height) / 3; $i++) { |
|
| 83 | + for ($i = 0; $i < ($width + $height) / 3; $i++) { |
|
| 84 | 84 | imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $line_color); |
| 85 | 85 | } |
| 86 | 86 | # To generate random rectangles using the imagerectangle PHP function, randomly generate the sizes |
| 87 | 87 | # of the rectangles as in the below code: |
| 88 | 88 | # generate random rectangles |
| 89 | - for ($i=0; $i < ($width + $height) / 3; $i++) { |
|
| 89 | + for ($i = 0; $i < ($width + $height) / 3; $i++) { |
|
| 90 | 90 | imagerectangle($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $rect_color); |
| 91 | 91 | } |
| 92 | 92 | # Create a bounding box of text using TrueType fonts. To do that, you can use the imagettfbbox PHP function: |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | # The most important step is writing the generated text on top of the generated image using the TrueType |
| 102 | 102 | # font. For this, you need the imagettftext PHP function. |
| 103 | - $urcX = ($width - $tb[4])/2; # tb[4] = upper right corner, X position |
|
| 104 | - $urcY = ($height - $tb[5])/2; # tb[5] = upper right corner, Y position |
|
| 103 | + $urcX = ($width - $tb[4]) / 2; # tb[4] = upper right corner, X position |
|
| 104 | + $urcY = ($height - $tb[5]) / 2; # tb[5] = upper right corner, Y position |
|
| 105 | 105 | # write the given text into the image using TrueType font |
| 106 | 106 | imagettftext($image, mt_rand(intval($height * 0.30), intval($height * 0.40)), 0, $urcX, $urcY, $captcha_color, $this->font, $text); |
| 107 | 107 | # For a nice design, you can go further and apply image filters. For example, you can apply |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | /** @var ArrayAccess */ |
| 21 | 21 | protected $cookie = null; |
| 22 | 22 | |
| 23 | - public function setHidden(string $alias, ArrayAccess &$cookie, string $errorMessage): self |
|
| 23 | + public function setHidden(string $alias, ArrayAccess & $cookie, string $errorMessage): self |
|
| 24 | 24 | { |
| 25 | 25 | $this->cookie = $cookie; |
| 26 | 26 | $this->setEntry($alias); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | $hashStack = $this->cookie->offsetExists($this->getKey() . 'SubmitCheck') |
| 66 | 66 | ? (array) json_decode($this->cookie->offsetGet($this->getKey() . 'SubmitCheck'), true) |
| 67 | - : null ; |
|
| 67 | + : null; |
|
| 68 | 68 | if (is_null($hashStack)) { |
| 69 | 69 | $hashStack = []; |
| 70 | 70 | } |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | return new Csrf\JWT(); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public function setHidden(string $alias, ArrayAccess &$cookie, string $errorMessage): self |
|
| 40 | + public function setHidden(string $alias, ArrayAccess & $cookie, string $errorMessage): self |
|
| 41 | 41 | { |
| 42 | 42 | $this->csrf->init($cookie); |
| 43 | 43 | $this->setEntry($alias); |
@@ -85,7 +85,7 @@ |
||
| 85 | 85 | return ''; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public function setLabel(/** @scrutinizer ignore-unused */?string $value): void |
|
| 88 | + public function setLabel(/** @scrutinizer ignore-unused */ ?string $value): void |
|
| 89 | 89 | { |
| 90 | 90 | } |
| 91 | 91 | |
@@ -20,6 +20,6 @@ |
||
| 20 | 20 | public function unpack(string $content): array |
| 21 | 21 | { |
| 22 | 22 | $data = @ unserialize($content); |
| 23 | - return (false === $data) ? [] : $data ; |
|
| 23 | + return (false === $data) ? [] : $data; |
|
| 24 | 24 | } |
| 25 | 25 | } |