| Conditions | 21 |
| Paths | 90 |
| Total Lines | 60 |
| Code Lines | 43 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 26 | public function handle(): int |
||
| 27 | { |
||
| 28 | $this->info('CAPTCHA Configuration Status'); |
||
| 29 | $this->info('================================'); |
||
| 30 | $this->newLine(); |
||
| 31 | |||
| 32 | $provider = config('captcha.provider', 'recaptcha'); |
||
| 33 | $this->line("Active Provider: <fg=cyan>{$provider}</>"); |
||
| 34 | $this->newLine(); |
||
| 35 | |||
| 36 | // Check reCAPTCHA |
||
| 37 | $this->info('Google reCAPTCHA:'); |
||
| 38 | $recaptchaEnabled = config('captcha.recaptcha.enabled'); |
||
| 39 | $recaptchaSitekey = config('captcha.recaptcha.sitekey'); |
||
| 40 | $recaptchaSecret = config('captcha.recaptcha.secret'); |
||
| 41 | |||
| 42 | $this->line(' Enabled: '.($recaptchaEnabled ? '<fg=green>Yes</>' : '<fg=red>No</>')); |
||
| 43 | $this->line(' Site Key: '.(! empty($recaptchaSitekey) ? '<fg=green>Configured</>' : '<fg=red>Missing</>')); |
||
| 44 | $this->line(' Secret: '.(! empty($recaptchaSecret) ? '<fg=green>Configured</>' : '<fg=red>Missing</>')); |
||
| 45 | $this->newLine(); |
||
| 46 | |||
| 47 | // Check Turnstile |
||
| 48 | $this->info('Cloudflare Turnstile:'); |
||
| 49 | $turnstileEnabled = config('captcha.turnstile.enabled'); |
||
| 50 | $turnstileSitekey = config('captcha.turnstile.sitekey'); |
||
| 51 | $turnstileSecret = config('captcha.turnstile.secret'); |
||
| 52 | |||
| 53 | $this->line(' Enabled: '.($turnstileEnabled ? '<fg=green>Yes</>' : '<fg=red>No</>')); |
||
| 54 | $this->line(' Site Key: '.(! empty($turnstileSitekey) ? '<fg=green>Configured</>' : '<fg=red>Missing</>')); |
||
| 55 | $this->line(' Secret: '.(! empty($turnstileSecret) ? '<fg=green>Configured</>' : '<fg=red>Missing</>')); |
||
| 56 | $this->newLine(); |
||
| 57 | |||
| 58 | // Validation |
||
| 59 | $recaptchaReady = $recaptchaEnabled && ! empty($recaptchaSitekey) && ! empty($recaptchaSecret); |
||
| 60 | $turnstileReady = $turnstileEnabled && ! empty($turnstileSitekey) && ! empty($turnstileSecret); |
||
| 61 | |||
| 62 | if ($recaptchaReady && $turnstileReady) { |
||
| 63 | $this->error('⚠ WARNING: Both providers are enabled!'); |
||
| 64 | $this->warn('Only one CAPTCHA provider should be enabled at a time.'); |
||
| 65 | $this->warn("The system will use: {$provider}"); |
||
| 66 | $this->newLine(); |
||
| 67 | } |
||
| 68 | |||
| 69 | if ($provider === 'recaptcha' && $recaptchaReady) { |
||
| 70 | $this->info('✓ reCAPTCHA is properly configured and active'); |
||
| 71 | } elseif ($provider === 'turnstile' && $turnstileReady) { |
||
| 72 | $this->info('✓ Turnstile is properly configured and active'); |
||
| 73 | } elseif ($provider === 'recaptcha' && ! $recaptchaReady) { |
||
| 74 | $this->error('✗ reCAPTCHA is selected but not properly configured'); |
||
| 75 | } elseif ($provider === 'turnstile' && ! $turnstileReady) { |
||
| 76 | $this->error('✗ Turnstile is selected but not properly configured'); |
||
| 77 | } else { |
||
| 78 | $this->warn('⚠ No CAPTCHA provider is active'); |
||
| 79 | } |
||
| 80 | |||
| 81 | $this->newLine(); |
||
| 82 | $this->comment('To change providers, update CAPTCHA_PROVIDER in your .env file'); |
||
| 83 | $this->comment('Then run: php artisan config:clear'); |
||
| 84 | |||
| 85 | return Command::SUCCESS; |
||
| 86 | } |
||
| 88 |