UploadCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 32
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 13 2
1
<?php
2
3
namespace Happyr\TranslationBundle\Command;
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
/**
11
 * This command will import your translations into your translator service
12
 */
13
class UploadCommand extends ContainerAwareCommand
14
{
15
    const RETURN_CODE_NO_FORCE = 2;
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    protected function configure()
21
    {
22
        $this
23
            ->setName('happyr:translation:upload')
24
            ->addOption('force', null, InputOption::VALUE_NONE, 'Set this parameter to execute this action')
25
            ->setDescription('Upload your translations into your translator service.');
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    protected function execute(InputInterface $input, OutputInterface $output)
32
    {
33
        if ($input->getOption('force')) {
34
            $this->getContainer()->get('happyr.translation')->uploadAllTranslations();
35
            $output->writeln('Upload complete');
36
        } else {
37
            $output->writeln('<error>ATTENTION:</error> This operation should not be executed in a production environment.');
38
            $output->writeln('');
39
            $output->writeln(sprintf('<info>This is going to replace every translations on your translator service.</info>'));
40
            $output->writeln('Please run the operation with --force to execute');
41
            return self::RETURN_CODE_NO_FORCE;
42
        }
43
    }
44
}
45