GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ImportCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 94.44%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 6
dl 0
loc 43
ccs 17
cts 18
cp 0.9444
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
B execute() 0 25 3
1
<?php
2
3
namespace EllipseSynergie\LocaleToYaml\Commands;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Yaml\Yaml;
10
use EllipseSynergie\LocaleToYaml\Exceptions\FileNotFoundException;
11
use EllipseSynergie\LocaleToYaml\Exceptions\YamlException;
12
use Symfony\Component\Yaml\Exception\ParseException;
13
14
/**
15
 * Class ImportCommand
16
 * @package EllipseSynergie\LocaleToYaml\Commands
17
 */
18
class ImportCommand extends Command
19
{
20
    /**
21
     */
22 3
    protected function configure()
23
    {
24 3
        $this->setName('lang:import-from-yaml')
25 3
            ->setDescription('Import locale file to PHP.')
26 3
            ->setHelp("This command allows you to import a lang file from comma-separated values to PHP...")
27 3
            ->addArgument('in', InputArgument::REQUIRED, 'The locale input filename.')
28 3
            ->addArgument('out', InputArgument::REQUIRED, 'The locale output filename.');
29 3
    }
30
31
    /**
32
     * @param InputInterface $input
33
     * @param OutputInterface $output
34
     */
35 2
    protected function execute(InputInterface $input, OutputInterface $output)
36
    {
37
        // Which file need to be converted back?
38 2
        $in = $input->getArgument('in');
39
        // To...
40 2
        $out = $input->getArgument('out');
41
42 2
        $output->writeln('Importing ' . $in . ' to ' . $out);
43
44 2
        if (!file_exists($in)) {
45 1
            throw new FileNotFoundException("Cannot find file " . $in);
46
        }
47
48
        try {
49
50
            // Get content from input file
51 1
            $strings = Yaml::parse(file_get_contents($in));
52
            // Output it to PHP file...
53 1
            file_put_contents($out, "<?php\n\nreturn " . var_export($strings, true) . ";");
54
55 1
        } catch (ParseException $e) {
56
57
            throw new YamlException("Not able to convert input file to Yaml.");
58
        }
59
    }
60
}