@@ -492,7 +492,7 @@ |
||
492 | 492 | * @param null $config |
493 | 493 | * @param array $attrs HTML attributes supplied to the image tag where key is the attribute |
494 | 494 | * and the value is the attribute value |
495 | - * @return string |
|
495 | + * @return HtmlString |
|
496 | 496 | */ |
497 | 497 | public function img($config = null, $attrs = []) |
498 | 498 | { |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $this->hasher = $hasher; |
204 | 204 | $this->str = $str; |
205 | 205 | $this->characters = config('captcha.characters', ['1', '2', '3', '4', '6', '7', '8', '9']); |
206 | - $this->fontsDirectory = config('captcha.fontsDirectory', __DIR__ . '/../assets/fonts'); |
|
206 | + $this->fontsDirectory = config('captcha.fontsDirectory', __DIR__.'/../assets/fonts'); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | */ |
213 | 213 | protected function configure($config) |
214 | 214 | { |
215 | - if ($this->config->has('captcha.' . $config)) { |
|
216 | - foreach ($this->config->get('captcha.' . $config) as $key => $val) { |
|
215 | + if ($this->config->has('captcha.'.$config)) { |
|
216 | + foreach ($this->config->get('captcha.'.$config) as $key => $val) { |
|
217 | 217 | $this->{$key} = $val; |
218 | 218 | } |
219 | 219 | } |
@@ -228,11 +228,11 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function create($config = 'default', $api = false) |
230 | 230 | { |
231 | - $this->backgrounds = $this->files->files(__DIR__ . '/../assets/backgrounds'); |
|
231 | + $this->backgrounds = $this->files->files(__DIR__.'/../assets/backgrounds'); |
|
232 | 232 | $this->fonts = $this->files->files($this->fontsDirectory); |
233 | 233 | |
234 | 234 | if (version_compare(app()->version(), '5.5.0', '>=')) { |
235 | - $this->fonts = array_map(function ($file) { |
|
235 | + $this->fonts = array_map(function($file) { |
|
236 | 236 | return $file->getPathName(); |
237 | 237 | }, $this->fonts); |
238 | 238 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | foreach ($text as $key => $char) { |
350 | 350 | $marginLeft = $this->textLeftPadding + ($key * ($this->image->width() - $this->textLeftPadding) / $this->length); |
351 | 351 | |
352 | - $this->image->text($char, $marginLeft, $marginTop, function ($font) { |
|
352 | + $this->image->text($char, $marginLeft, $marginTop, function($font) { |
|
353 | 353 | $font->file($this->font()); |
354 | 354 | $font->size($this->fontSize()); |
355 | 355 | $font->color($this->fontColor()); |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | */ |
388 | 388 | protected function fontColor() |
389 | 389 | { |
390 | - if (!empty($this->fontColors)) { |
|
390 | + if ( ! empty($this->fontColors)) { |
|
391 | 391 | $color = $this->fontColors[rand(0, count($this->fontColors) - 1)]; |
392 | 392 | } else { |
393 | 393 | $color = [rand(0, 255), rand(0, 255), rand(0, 255)]; |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | rand(0, $this->image->height()), |
420 | 420 | rand(0, $this->image->width()), |
421 | 421 | rand(0, $this->image->height()), |
422 | - function ($draw) { |
|
422 | + function($draw) { |
|
423 | 423 | $draw->color($this->fontColor()); |
424 | 424 | } |
425 | 425 | ); |
@@ -436,14 +436,14 @@ discard block |
||
436 | 436 | */ |
437 | 437 | public function check($value) |
438 | 438 | { |
439 | - if (!$this->session->has('captcha')) { |
|
439 | + if ( ! $this->session->has('captcha')) { |
|
440 | 440 | return false; |
441 | 441 | } |
442 | 442 | |
443 | 443 | $key = $this->session->get('captcha.key'); |
444 | 444 | $sensitive = $this->session->get('captcha.sensitive'); |
445 | 445 | |
446 | - if (!$sensitive) { |
|
446 | + if ( ! $sensitive) { |
|
447 | 447 | $value = $this->str->lower($value); |
448 | 448 | } |
449 | 449 | |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | */ |
476 | 476 | public function src($config = null) |
477 | 477 | { |
478 | - return url('captcha' . ($config ? '/' . $config : '/default')) . '?' . $this->str->random(8); |
|
478 | + return url('captcha'.($config ? '/'.$config : '/default')).'?'.$this->str->random(8); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | /** |
@@ -495,8 +495,8 @@ discard block |
||
495 | 495 | continue; |
496 | 496 | } |
497 | 497 | |
498 | - $attrs_str .= $attr . '="' . $value . '" '; |
|
498 | + $attrs_str .= $attr.'="'.$value.'" '; |
|
499 | 499 | } |
500 | - return new HtmlString('<img src="' . $this->src($config) . '" ' . trim($attrs_str) . '>'); |
|
500 | + return new HtmlString('<img src="'.$this->src($config).'" '.trim($attrs_str).'>'); |
|
501 | 501 | } |
502 | 502 | } |
@@ -18,7 +18,6 @@ |
||
18 | 18 | use Illuminate\Config\Repository; |
19 | 19 | use Illuminate\Hashing\BcryptHasher as Hasher; |
20 | 20 | use Illuminate\Filesystem\Filesystem; |
21 | -use Illuminate\Support\Facades\Crypt; |
|
22 | 21 | use Illuminate\Support\Str; |
23 | 22 | use Intervention\Image\Image; |
24 | 23 | use Intervention\Image\ImageManager; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!function_exists('captcha')) { |
|
3 | +if ( ! function_exists('captcha')) { |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * @param string $config |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | } |
13 | 13 | } |
14 | 14 | |
15 | -if (!function_exists('captcha_src')) { |
|
15 | +if ( ! function_exists('captcha_src')) { |
|
16 | 16 | /** |
17 | 17 | * @param string $config |
18 | 18 | * @return string |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
26 | -if (!function_exists('captcha_img')) { |
|
26 | +if ( ! function_exists('captcha_img')) { |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * @param string $config |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | -if (!function_exists('captcha_check')) { |
|
38 | +if ( ! function_exists('captcha_check')) { |
|
39 | 39 | /** |
40 | 40 | * @param $value |
41 | 41 | * @return bool |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | -if (!function_exists('captcha_api_check')) { |
|
49 | +if ( ! function_exists('captcha_api_check')) { |
|
50 | 50 | /** |
51 | 51 | * @param $value |
52 | 52 | * @return bool |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | { |
20 | 20 | // Publish configuration files |
21 | 21 | $this->publishes([ |
22 | - __DIR__ . '/../config/captcha.php' => config_path('captcha.php') |
|
22 | + __DIR__.'/../config/captcha.php' => config_path('captcha.php') |
|
23 | 23 | ], 'config'); |
24 | 24 | |
25 | 25 | // HTTP routing |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $this->app->get('captcha[/api/{config}]', 'Mews\Captcha\LumenCaptchaController@getCaptchaApi'); |
28 | 28 | $this->app->get('captcha[/{config}]', 'Mews\Captcha\LumenCaptchaController@getCaptcha'); |
29 | 29 | } else { |
30 | - if ((double)$this->app->version() >= 5.2) { |
|
30 | + if ((double) $this->app->version() >= 5.2) { |
|
31 | 31 | $this->app['router']->get('captcha/api/{config?}', '\Mews\Captcha\CaptchaController@getCaptchaApi')->middleware('web'); |
32 | 32 | $this->app['router']->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha')->middleware('web'); |
33 | 33 | } else { |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | // Validator extensions |
40 | - $this->app['validator']->extend('captcha', function ($attribute, $value, $parameters) { |
|
40 | + $this->app['validator']->extend('captcha', function($attribute, $value, $parameters) { |
|
41 | 41 | return captcha_check($value); |
42 | 42 | }); |
43 | 43 | |
44 | 44 | // Validator extensions |
45 | - $this->app['validator']->extend('captcha_api', function ($attribute, $value, $parameters) { |
|
45 | + $this->app['validator']->extend('captcha_api', function($attribute, $value, $parameters) { |
|
46 | 46 | return captcha_api_check($value, $parameters[0]); |
47 | 47 | }); |
48 | 48 | } |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | { |
57 | 57 | // Merge configs |
58 | 58 | $this->mergeConfigFrom( |
59 | - __DIR__ . '/../config/captcha.php', 'captcha' |
|
59 | + __DIR__.'/../config/captcha.php', 'captcha' |
|
60 | 60 | ); |
61 | 61 | |
62 | 62 | // Bind captcha |
63 | - $this->app->bind('captcha', function ($app) { |
|
63 | + $this->app->bind('captcha', function($app) { |
|
64 | 64 | return new Captcha( |
65 | 65 | $app['Illuminate\Filesystem\Filesystem'], |
66 | 66 | $app['Illuminate\Config\Repository'], |