Passed
Pull Request — master (#335)
by Alexander
03:40
created

ExtractTranslationsCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 12
ccs 0
cts 8
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
12
class ExtractTranslationsCommand extends Command
13
{
14
    public function __construct()
15
    {
16
        parent::__construct('translation/extract');
17
    }
18
19
    protected function configure()
20
    {
21
        $this->addArgument('path', InputArgument::REQUIRED, 'The path where the extractor will search for messages');
22
    }
23
24
    protected function execute(InputInterface $input, OutputInterface $output)
25
    {
26
        $path = $input->getArgument('path');
27
        $extractor = new \Yiisoft\Translator\Extractor\TranslationExtractor($path);
28
29
        $defaultCategory = 'app';
30
        $translatorCall = '->translate';
31
32
        $messages = $extractor->extract($defaultCategory, $translatorCall);
33
34
        print_r($messages);
35
        return 0;
36
    }
37
}
38