@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | $this->hasher = $hasher; |
| 205 | 205 | $this->str = $str; |
| 206 | 206 | $this->characters = config('captcha.characters', ['1', '2', '3', '4', '6', '7', '8', '9']); |
| 207 | - $this->fontsDirectory = config('captcha.fontsDirectory', __DIR__ . '/../assets/fonts'); |
|
| 207 | + $this->fontsDirectory = config('captcha.fontsDirectory', __DIR__.'/../assets/fonts'); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | protected function configure($config) |
| 215 | 215 | { |
| 216 | - if ($this->config->has('captcha.' . $config)) { |
|
| 217 | - foreach ($this->config->get('captcha.' . $config) as $key => $val) { |
|
| 216 | + if ($this->config->has('captcha.'.$config)) { |
|
| 217 | + foreach ($this->config->get('captcha.'.$config) as $key => $val) { |
|
| 218 | 218 | $this->{$key} = $val; |
| 219 | 219 | } |
| 220 | 220 | } |
@@ -230,11 +230,11 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | public function create(string $config = 'default', bool $api = false) |
| 232 | 232 | { |
| 233 | - $this->backgrounds = $this->files->files(__DIR__ . '/../assets/backgrounds'); |
|
| 233 | + $this->backgrounds = $this->files->files(__DIR__.'/../assets/backgrounds'); |
|
| 234 | 234 | $this->fonts = $this->files->files($this->fontsDirectory); |
| 235 | 235 | |
| 236 | 236 | if (version_compare(app()->version(), '5.5.0', '>=')) { |
| 237 | - $this->fonts = array_map(function ($file) { |
|
| 237 | + $this->fonts = array_map(function($file) { |
|
| 238 | 238 | /* @var File $file */ |
| 239 | 239 | return $file->getPathName(); |
| 240 | 240 | }, $this->fonts); |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | foreach ($text as $key => $char) { |
| 355 | 355 | $marginLeft = $this->textLeftPadding + ($key * ($this->image->width() - $this->textLeftPadding) / $this->length); |
| 356 | 356 | |
| 357 | - $this->image->text($char, $marginLeft, $marginTop, function ($font) { |
|
| 357 | + $this->image->text($char, $marginLeft, $marginTop, function($font) { |
|
| 358 | 358 | /* @var Font $font */ |
| 359 | 359 | $font->file($this->font()); |
| 360 | 360 | $font->size($this->fontSize()); |
@@ -393,10 +393,10 @@ discard block |
||
| 393 | 393 | */ |
| 394 | 394 | protected function fontColor(): string |
| 395 | 395 | { |
| 396 | - if (!empty($this->fontColors)) { |
|
| 396 | + if ( ! empty($this->fontColors)) { |
|
| 397 | 397 | $color = $this->fontColors[rand(0, count($this->fontColors) - 1)]; |
| 398 | 398 | } else { |
| 399 | - $color = '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT); |
|
| 399 | + $color = '#'.str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | return $color; |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | rand(0, $this->image->height()), |
| 426 | 426 | rand(0, $this->image->width()), |
| 427 | 427 | rand(0, $this->image->height()), |
| 428 | - function ($draw) { |
|
| 428 | + function($draw) { |
|
| 429 | 429 | /* @var Font $draw */ |
| 430 | 430 | $draw->color($this->fontColor()); |
| 431 | 431 | } |
@@ -443,14 +443,14 @@ discard block |
||
| 443 | 443 | */ |
| 444 | 444 | public function check(string $value): bool |
| 445 | 445 | { |
| 446 | - if (!$this->session->has('captcha')) { |
|
| 446 | + if ( ! $this->session->has('captcha')) { |
|
| 447 | 447 | return false; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | $key = $this->session->get('captcha.key'); |
| 451 | 451 | $sensitive = $this->session->get('captcha.sensitive'); |
| 452 | 452 | |
| 453 | - if (!$sensitive) { |
|
| 453 | + if ( ! $sensitive) { |
|
| 454 | 454 | $value = $this->str->lower($value); |
| 455 | 455 | } |
| 456 | 456 | |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | */ |
| 484 | 484 | public function src(?string $config): string |
| 485 | 485 | { |
| 486 | - return url('captcha' . ($config ? '/' . $config : '/default')) . '?' . $this->str->random(8); |
|
| 486 | + return url('captcha'.($config ? '/'.$config : '/default')).'?'.$this->str->random(8); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | /** |
@@ -503,8 +503,8 @@ discard block |
||
| 503 | 503 | continue; |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | - $attrs_str .= $attr . '="' . $value . '" '; |
|
| 506 | + $attrs_str .= $attr.'="'.$value.'" '; |
|
| 507 | 507 | } |
| 508 | - return new HtmlString('<img src="' . $this->src($config) . '" ' . trim($attrs_str) . '>'); |
|
| 508 | + return new HtmlString('<img src="'.$this->src($config).'" '.trim($attrs_str).'>'); |
|
| 509 | 509 | } |
| 510 | 510 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | { |
| 22 | 22 | // Publish configuration files |
| 23 | 23 | $this->publishes([ |
| 24 | - __DIR__ . '/../config/captcha.php' => config_path('captcha.php') |
|
| 24 | + __DIR__.'/../config/captcha.php' => config_path('captcha.php') |
|
| 25 | 25 | ], 'config'); |
| 26 | 26 | |
| 27 | 27 | // HTTP routing |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | } else { |
| 34 | 34 | /* @var Router $router */ |
| 35 | 35 | $router = $this->app['router']; |
| 36 | - if ((double)$this->app->version() >= 5.2) { |
|
| 36 | + if ((double) $this->app->version() >= 5.2) { |
|
| 37 | 37 | $router->get('captcha/api/{config?}', '\Mews\Captcha\CaptchaController@getCaptchaApi')->middleware('web'); |
| 38 | 38 | $router->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha')->middleware('web'); |
| 39 | 39 | } else { |
@@ -46,12 +46,12 @@ discard block |
||
| 46 | 46 | $validator = $this->app['validator']; |
| 47 | 47 | |
| 48 | 48 | // Validator extensions |
| 49 | - $validator->extend('captcha', function ($attribute, $value, $parameters) { |
|
| 49 | + $validator->extend('captcha', function($attribute, $value, $parameters) { |
|
| 50 | 50 | return captcha_check($value); |
| 51 | 51 | }); |
| 52 | 52 | |
| 53 | 53 | // Validator extensions |
| 54 | - $validator->extend('captcha_api', function ($attribute, $value, $parameters) { |
|
| 54 | + $validator->extend('captcha_api', function($attribute, $value, $parameters) { |
|
| 55 | 55 | return captcha_api_check($value, $parameters[0]); |
| 56 | 56 | }); |
| 57 | 57 | } |
@@ -65,12 +65,12 @@ discard block |
||
| 65 | 65 | { |
| 66 | 66 | // Merge configs |
| 67 | 67 | $this->mergeConfigFrom( |
| 68 | - __DIR__ . '/../config/captcha.php', |
|
| 68 | + __DIR__.'/../config/captcha.php', |
|
| 69 | 69 | 'captcha' |
| 70 | 70 | ); |
| 71 | 71 | |
| 72 | 72 | // Bind captcha |
| 73 | - $this->app->bind('captcha', function ($app) { |
|
| 73 | + $this->app->bind('captcha', function($app) { |
|
| 74 | 74 | return new Captcha( |
| 75 | 75 | $app['Illuminate\Filesystem\Filesystem'], |
| 76 | 76 | $app['Illuminate\Config\Repository'], |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | use Intervention\Image\ImageManager; |
| 4 | 4 | |
| 5 | -if (!function_exists('captcha')) { |
|
| 5 | +if ( ! function_exists('captcha')) { |
|
| 6 | 6 | /** |
| 7 | 7 | * @param string $config |
| 8 | 8 | * @return array|ImageManager|mixed |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | } |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | -if (!function_exists('captcha_src')) { |
|
| 17 | +if ( ! function_exists('captcha_src')) { |
|
| 18 | 18 | /** |
| 19 | 19 | * @param string $config |
| 20 | 20 | * @return string |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | -if (!function_exists('captcha_img')) { |
|
| 28 | +if ( ! function_exists('captcha_img')) { |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * @param string $config |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | -if (!function_exists('captcha_check')) { |
|
| 40 | +if ( ! function_exists('captcha_check')) { |
|
| 41 | 41 | /** |
| 42 | 42 | * @param string $value |
| 43 | 43 | * @return bool |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | -if (!function_exists('captcha_api_check')) { |
|
| 51 | +if ( ! function_exists('captcha_api_check')) { |
|
| 52 | 52 | /** |
| 53 | 53 | * @param string $value |
| 54 | 54 | * @param string $key |