FormatCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 12 1
A execute() 0 20 2
1
<?php
2
3
namespace Decline\TransformatBundle\Command;
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Symfony\Component\Console\Style\SymfonyStyle;
10
11
/**
12
 * Class FormatCommand
13
 * @package Decline\TransformatBundle\Command
14
 */
15
class FormatCommand extends ContainerAwareCommand
16
{
17
18
    const ARGUMENT_FILENAME = 'filename';
19
20
    const COMMAND_NAME = 'transformat:format';
21
22
    /**
23
     * Configuration for the FormatCommand
24
     */
25 5
    protected function configure()
26
    {
27
        $this
28 5
            ->addArgument(
29 5
                static::ARGUMENT_FILENAME,
30 5
                InputArgument::OPTIONAL,
31 5
                'A single filename in the configured directory.'
32
            )
33 5
            ->setName(static::COMMAND_NAME)
34 5
            ->setDescription('Format translation files.')
35 5
            ->setHelp('Formats the configured set of translation files and performs some validity checks.');
36 5
    }
37
38
    /**
39
     *
40
     * @param InputInterface $input
41
     * @param OutputInterface $output
42
     * @return int|null|void
43
     */
44 5
    protected function execute(InputInterface $input, OutputInterface $output)
45
    {
46 5
        $io = new SymfonyStyle($input, $output);
47 5
        $io->title('Decline Transformat Bundle');
48
49 5
        $io->text('Starting to format translation files:');
50
51 5
        $errors = $this->getContainer()->get('decline_transformat.format')->format(
52
            $io,
53 5
            $input->getArgument(static::ARGUMENT_FILENAME)
54
        );
55
56 5
        $io->newLine();
57
58 5
        if (count($errors)) {
59 4
            $io->error($errors);
60
        } else {
61 1
            $io->success('Done.');
62
        }
63
    }
64
}