ListLanguageCommand::execute()   A
last analyzed

Complexity

Conditions 2
Paths 3

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 3
nop 2
1
<?php
2
3
/*
4
 * This file is part of the SexyField package.
5
 *
6
 * (c) Dion Snoeijen <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare (strict_types = 1);
13
14
namespace Tardigrades\Command;
15
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
use Tardigrades\SectionField\Service\LanguageManagerInterface;
19
use Tardigrades\SectionField\Service\LanguageNotFoundException;
20
21
class ListLanguageCommand extends LanguageCommand
22
{
23
    private $languageManager;
24
25
    public function __construct(
26
        LanguageManagerInterface $languageManager
27
    ) {
28
        $this->languageManager = $languageManager;
29
30
        parent::__construct('sf:list-language');
31
    }
32
33
    protected function configure()
34
    {
35
        $this
36
            ->setDescription('List language')
37
            ->setHelp('List all installed languages');
38
    }
39
40
    protected function execute(InputInterface $input, OutputInterface $output)
41
    {
42
        try {
43
            $languages = $this->languageManager->readAll();
44
            $this->renderTable($output, $languages, 'All installed languages');
45
        } catch (LanguageNotFoundException $exception) {
46
            $output->writeln('No language found');
47
        }
48
    }
49
}
50