Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| RegenerateAppSecretCommand | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| __invoke | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Command; |
| 6 | |
| 7 | use Random\RandomException; |
| 8 | use Symfony\Component\Console\Attribute\AsCommand; |
| 9 | use Symfony\Component\Console\Command\Command; |
| 10 | use Symfony\Component\Console\Style\SymfonyStyle; |
| 11 | |
| 12 | #[AsCommand( |
| 13 | name: 'gen-secret', |
| 14 | description: 'Generate a new secret key', |
| 15 | )] |
| 16 | class RegenerateAppSecretCommand |
| 17 | { |
| 18 | /** |
| 19 | * @throws RandomException |
| 20 | */ |
| 21 | public function __invoke(SymfonyStyle $io): int |
| 22 | { |
| 23 | $secret = bin2hex(random_bytes(16)); |
| 24 | |
| 25 | $msg = "Your secret key {$secret} \nplease replace this key with your APP_SECRET in .env file"; |
| 26 | |
| 27 | $io->success($msg); |
| 28 | |
| 29 | return Command::SUCCESS; |
| 30 | } |
| 31 | } |