@@ -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 |
@@ -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 | } |
@@ -20,6 +20,6 @@ |
||
| 20 | 20 | public function unpack(string $content): array |
| 21 | 21 | { |
| 22 | 22 | $data = @ json_decode($content, true); |
| 23 | - return (false === $data) ? [] : $data ; |
|
| 23 | + return (false === $data) ? [] : $data; |
|
| 24 | 24 | } |
| 25 | 25 | } |
@@ -22,13 +22,13 @@ |
||
| 22 | 22 | /** @var int How log interval is preset after correct response */ |
| 23 | 23 | protected int $timeout = 0; |
| 24 | 24 | |
| 25 | - public function __construct(ArrayAccess &$session, int $timeout = 0) |
|
| 25 | + public function __construct(ArrayAccess & $session, int $timeout = 0) |
|
| 26 | 26 | { |
| 27 | 27 | $this->session = $session; |
| 28 | 28 | $this->timeout = $timeout; |
| 29 | 29 | $this->time = ($this->session->offsetExists(static::CAPTCHA_TIME)) |
| 30 | 30 | ? intval(strval($this->session->offsetGet(static::CAPTCHA_TIME))) |
| 31 | - : 0 ; |
|
| 31 | + : 0; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function updateExpire(): void |