Completed
Push — master ( b53e51...1009f9 )
by Alejandro
04:13 queued 38s
created

LanguageConfigCustomizerPlugin   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 37
ccs 16
cts 16
cp 1
rs 10
wmc 3
lcom 1
cbo 5

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 25 3
1
<?php
2
namespace Shlinkio\Shlink\CLI\Install\Plugin;
3
4
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
5
use Symfony\Component\Console\Exception\RuntimeException;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Console\Question\ChoiceQuestion;
9
use Symfony\Component\Console\Question\ConfirmationQuestion;
10
11
class LanguageConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin
12
{
13
    const SUPPORTED_LANGUAGES = ['en', 'es'];
14
15
    /**
16
     * @param InputInterface $input
17
     * @param OutputInterface $output
18
     * @param CustomizableAppConfig $appConfig
19
     * @return void
20
     * @throws RuntimeException
21
     */
22 3
    public function process(InputInterface $input, OutputInterface $output, CustomizableAppConfig $appConfig)
23
    {
24 3
        $this->printTitle($output, 'LANGUAGE');
25
26 3
        if ($appConfig->hasLanguage() && $this->questionHelper->ask($input, $output, new ConfirmationQuestion(
27
            '<question>Do you want to keep imported language? (Y/n):</question> '
28 3
        ))) {
29 1
            return;
30
        }
31
32 2
        $appConfig->setLanguage([
33 2
            'DEFAULT' => $this->questionHelper->ask($input, $output, new ChoiceQuestion(
34
                '<question>Select default language for the application in general (defaults to '
35 2
                . self::SUPPORTED_LANGUAGES[0] . '):</question>',
36 2
                self::SUPPORTED_LANGUAGES,
37
                0
38 2
            )),
39 2
            'CLI' => $this->questionHelper->ask($input, $output, new ChoiceQuestion(
40
                '<question>Select default language for CLI executions (defaults to '
41 2
                . self::SUPPORTED_LANGUAGES[0] . '):</question>',
42 2
                self::SUPPORTED_LANGUAGES,
43
                0
44 2
            )),
45 2
        ]);
46 2
    }
47
}
48