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

TranslateCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
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