Completed
Push — master ( d7e919...298f7d )
by Simonas
64:16
created

ExportCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 75.86%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 1
cbo 5
dl 0
loc 54
ccs 22
cts 29
cp 0.7586
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 17 1
B execute() 0 27 3
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[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
namespace ONGR\TranslationsBundle\Command;
13
14
use ONGR\TranslationsBundle\Service\Export\ExportManager;
15
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Input\InputOption;
18
use Symfony\Component\Console\Output\OutputInterface;
19
20
/**
21
 * Exports translations.
22
 */
23
class ExportCommand extends ContainerAwareCommand
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28 4
    protected function configure()
29
    {
30 4
        $this->setName('ongr:translations:export');
31 4
        $this->setDescription('Export all translations from ES to yaml.');
32 4
        $this->addOption(
33 4
            'locales',
34 4
            'l',
35 4
            InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
36 4
            'Export only these locales, instead of using the managed locales.'
37
        );
38 4
        $this->addOption(
39 4
            'force',
40 4
            'f',
41 4
            InputOption::VALUE_NONE,
42 4
            'If set, the bundle will export all translations, regardless of status'
43 4
        );
44
    }
45 4
46
    /**
47
     * {@inheritdoc}
48
     */
49
    protected function execute(InputInterface $input, OutputInterface $output)
50 4
    {
51
        /** @var ExportManager $export */
52
        $export = $this->getContainer()->get('ongr_translations.export');
53 4
54
        $locales = $input->getOption('locales');
55 4
        if (!empty($locales)) {
56 4
            $export->setManagedLocales($locales);
0 ignored issues
show
Bug introduced by
The method setManagedLocales() does not seem to exist on object<ONGR\Translations...e\Export\ExportManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57 1
        }
58
59
        $domains = $input->getOption('domains');
60 4
        $export->export($domains, $input->getOption('force'));
61 4
62
        $prettify = function ($array) {
63
            return !empty($array) ? implode('</comment><info>`, `</info><comment>', $array) : 'all';
64
        };
65
66
        $output->writeln(
67
            sprintf(
68
                '<info>Successfully exported translations in `</info>'
69
                . '<comment>%s</comment><info>` locale(s) for `</info>'
70
                . '<comment>%s</comment><info>` domain(s).</info>',
71
                $prettify($locales),
72
                $prettify($domains)
73
            )
74
        );
75
    }
76
}
77