Completed
Pull Request — master (#148)
by Alejandro
04:22
created

ApplicationConfigCustomizer::process()   B

Complexity

Conditions 4
Paths 2

Size

Total Lines 25
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 4.0032

Importance

Changes 0
Metric Value
cc 4
eloc 17
c 0
b 0
f 0
nc 2
nop 2
dl 0
loc 25
ccs 16
cts 17
cp 0.9412
crap 4.0032
rs 8.5806
1
<?php
2
declare(strict_types=1);
3
4
namespace Shlinkio\Shlink\CLI\Install\Plugin;
5
6
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
7
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
8
use Symfony\Component\Console\Style\SymfonyStyle;
9
10
class ApplicationConfigCustomizer implements ConfigCustomizerInterface
11
{
12
    use StringUtilsTrait;
13
14
    /**
15
     * @param SymfonyStyle $io
16
     * @param CustomizableAppConfig $appConfig
17
     * @return void
18
     */
19 3
    public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig)
20
    {
21 3
        $io->title('APPLICATION');
22
23 3
        if ($appConfig->hasApp() && $io->confirm('Do you want to keep imported application config?')) {
24 1
            return;
25
        }
26
27
        $validator = function ($value) {
28
            return $value;
29 2
        };
30 2
        $appConfig->setApp([
31 2
            'SECRET' => $io->ask(
32 2
                'Define a secret string that will be used to sign API tokens (leave empty to autogenerate one)',
33 2
                null,
34 2
                $validator
35 2
            ) ?: $this->generateRandomString(32),
36 2
            'DISABLE_TRACK_PARAM' => $io->ask(
37
                'Provide a parameter name that you will be able to use to disable tracking on specific request to '
38 2
                . 'short URLs (leave empty and this feature won\'t be enabled)',
39 2
                null,
40 2
                $validator
41
            ),
42
        ]);
43 2
    }
44
}
45