Passed
Pull Request — master (#335)
by Dmitriy
03:24
created

TranslateCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 20
ccs 0
cts 11
cp 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 5 1
A __construct() 0 4 1
A configure() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Command\Translation;
6
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
use Yiisoft\Translator\TranslatorInterface;
12
13
final class TranslateCommand extends Command
14
{
15
    private TranslatorInterface $translator;
16
17
    public function __construct(TranslatorInterface $translator)
18
    {
19
        parent::__construct('app/translation/translate');
20
        $this->translator = $translator;
21
    }
22
23
    protected function configure()
24
    {
25
        $this->addArgument('message', InputArgument::REQUIRED, 'Message that will be translated.');
26
    }
27
28
    protected function execute(InputInterface $input, OutputInterface $output)
29
    {
30
        $message = $input->getArgument('message');
31
        $output->writeln($this->translator->translate($message));
32
        return 0;
33
    }
34
}
35