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.
Completed
Push — master ( 5182b7...f60ec3 )
by Dominic
02:54
created

ImportCommand::execute()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 25
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3.0067

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 10
cts 11
cp 0.9091
rs 8.8571
c 0
b 0
f 0
cc 3
eloc 11
nc 4
nop 2
crap 3.0067
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
}