@@ -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 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | if ($canSet) { |
| 47 | 47 | $this->assertFalse($adapter->offsetExists('fee')); |
| 48 | - $adapter->offsetSet('fee','nnn'); |
|
| 48 | + $adapter->offsetSet('fee', 'nnn'); |
|
| 49 | 49 | $this->assertTrue($adapter->offsetExists('fee')); |
| 50 | 50 | $adapter->offsetUnset('fee'); |
| 51 | 51 | $this->assertFalse($adapter->offsetExists('fee')); |
@@ -68,15 +68,15 @@ discard block |
||
| 68 | 68 | 'xggxgx' => $entry, |
| 69 | 69 | ]; |
| 70 | 70 | return [ |
| 71 | - [new \Adapter(), '', true, true, true, true ], |
|
| 72 | - [new Adapters\ArrayAdapter($_GET), IEntry::SOURCE_GET, true, true, true, true ], |
|
| 73 | - [new Adapters\VarsAdapter(), IEntry::SOURCE_GET, true, false, true, true ], |
|
| 74 | - [new Adapters\VarsAdapter(), IEntry::SOURCE_POST, false, false, false, true ], |
|
| 75 | - [new Adapters\SessionAdapter(), '', false, false, false, true ], |
|
| 76 | - [new \Files(), '', false, false, false, false ], |
|
| 71 | + [new \Adapter(), '', true, true, true, true], |
|
| 72 | + [new Adapters\ArrayAdapter($_GET), IEntry::SOURCE_GET, true, true, true, true], |
|
| 73 | + [new Adapters\VarsAdapter(), IEntry::SOURCE_GET, true, false, true, true], |
|
| 74 | + [new Adapters\VarsAdapter(), IEntry::SOURCE_POST, false, false, false, true], |
|
| 75 | + [new Adapters\SessionAdapter(), '', false, false, false, true], |
|
| 76 | + [new \Files(), '', false, false, false, false], |
|
| 77 | 77 | [new Adapters\InputVarsAdapter(new Filtered\Json( |
| 78 | 78 | '{"foo":"aff","bar":"poa","baz":"cdd","sgg":"arr","sd#,\'srs":"ggsd<$=","dsr.!>sd":"zfd?-\"","dg-[]":"dc^&#~\\\u20ac`~\u00b0","dg[]":"<?php =!@#dc^&#~","xggxgx":"free"}' |
| 79 | - )), IEntry::SOURCE_JSON, true, true, true, true ], |
|
| 79 | + )), IEntry::SOURCE_JSON, true, true, true, true], |
|
| 80 | 80 | ]; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -179,12 +179,12 @@ discard block |
||
| 179 | 179 | public function factoryProvider(): array |
| 180 | 180 | { |
| 181 | 181 | return [ |
| 182 | - [Controls\Security\Captcha\Factory::TYPE_DISABLED, Controls\Security\Captcha\Disabled::class], |
|
| 183 | - [Controls\Security\Captcha\Factory::TYPE_TEXT, Controls\Security\Captcha\Text::class], |
|
| 184 | - [Controls\Security\Captcha\Factory::TYPE_MATH, Controls\Security\Captcha\Numerical::class], |
|
| 185 | - [Controls\Security\Captcha\Factory::TYPE_COLOUR, Controls\Security\Captcha\ColourfulText::class], |
|
| 182 | + [Controls\Security\Captcha\Factory::TYPE_DISABLED, Controls\Security\Captcha\Disabled::class], |
|
| 183 | + [Controls\Security\Captcha\Factory::TYPE_TEXT, Controls\Security\Captcha\Text::class], |
|
| 184 | + [Controls\Security\Captcha\Factory::TYPE_MATH, Controls\Security\Captcha\Numerical::class], |
|
| 185 | + [Controls\Security\Captcha\Factory::TYPE_COLOUR, Controls\Security\Captcha\ColourfulText::class], |
|
| 186 | 186 | [Controls\Security\Captcha\Factory::TYPE_NOCAPTCHA, Controls\Security\Captcha\Nocaptcha::class], |
| 187 | - [123, Controls\Security\Captcha\Text::class], |
|
| 187 | + [123, Controls\Security\Captcha\Text::class], |
|
| 188 | 188 | ]; |
| 189 | 189 | } |
| 190 | 190 | } |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | class Graphical extends Controls\Security\Captcha\AGraphical |
| 199 | 199 | { |
| 200 | - public function set(string $alias, ArrayAccess &$session, string $errorMessage, string $font = ''): self |
|
| 200 | + public function set(string $alias, ArrayAccess & $session, string $errorMessage, string $font = ''): self |
|
| 201 | 201 | { |
| 202 | 202 | $this->font = $font; |
| 203 | 203 | $text = strtolower($this->generateRandomString(8)); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public function current() |
| 29 | 29 | { |
| 30 | - return $this->valid() ? $this->offsetGet($this->key) : null ; |
|
| 30 | + return $this->valid() ? $this->offsetGet($this->key) : null; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function next() |
@@ -118,14 +118,14 @@ discard block |
||
| 118 | 118 | protected function fileDataset(): array |
| 119 | 119 | { |
| 120 | 120 | return [ |
| 121 | - 'files' => [ // simple upload |
|
| 121 | + 'files' => [// simple upload |
|
| 122 | 122 | 'name' => 'facepalm.jpg', |
| 123 | 123 | 'type' => 'image/jpeg', |
| 124 | 124 | 'tmp_name' => '/tmp/php3zU3t5', |
| 125 | 125 | 'error' => UPLOAD_ERR_OK, |
| 126 | 126 | 'size' => 591387, |
| 127 | 127 | ], |
| 128 | - 'download' => [ // multiple upload |
|
| 128 | + 'download' => [// multiple upload |
|
| 129 | 129 | 'name' => [ |
| 130 | 130 | 'file1' => 'MyFile.txt', |
| 131 | 131 | 'file2' => 'MyFile.jpg', |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | 'file2' => 3075, |
| 148 | 148 | ], |
| 149 | 149 | ], |
| 150 | - 'numbered' => [ // multiple upload |
|
| 150 | + 'numbered' => [// multiple upload |
|
| 151 | 151 | 'name' => [ |
| 152 | 152 | 0 => 'MyFile.txt', |
| 153 | 153 | 1 => 'MyFile.jpg', |