Completed
Pull Request — master (#278)
by Alejandro
03:36 queued 01:25
created

GenerateCharsetCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Shlinkio\Shlink\CLI\Command\Config;
5
6
use Shlinkio\Shlink\Core\Service\UrlShortener;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Symfony\Component\Console\Style\SymfonyStyle;
11
use function sprintf;
12
use function str_shuffle;
13
14
class GenerateCharsetCommand extends Command
15
{
16
    public const NAME = 'config:generate-charset';
17
18 1
    protected function configure(): void
19
    {
20
        $this
21 1
            ->setName(self::NAME)
22 1
            ->setDescription(sprintf(
23
                'Generates a character set sample just by shuffling the default one, "%s". '
24 1
                . 'Then it can be set in the SHORTCODE_CHARS environment variable',
25 1
                UrlShortener::DEFAULT_CHARS
26
            ));
27
    }
28
29 1
    protected function execute(InputInterface $input, OutputInterface $output): void
30
    {
31 1
        $charSet = str_shuffle(UrlShortener::DEFAULT_CHARS);
32 1
        (new SymfonyStyle($input, $output))->success(sprintf('Character set: "%s"', $charSet));
33
    }
34
}
35