Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
RegenerateAppSecretCommand
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 __invoke
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Command;
6
7use Random\RandomException;
8use Symfony\Component\Console\Attribute\AsCommand;
9use Symfony\Component\Console\Command\Command;
10use Symfony\Component\Console\Style\SymfonyStyle;
11
12#[AsCommand(
13    name: 'gen-secret',
14    description: 'Generate a new secret key',
15)]
16class 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}