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.

ExportCommand::execute()   B
last analyzed

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 EllipseSynergie\LocaleToYaml\Exceptions\YamlException;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Symfony\Component\Console\Input\InputArgument;
10
use Symfony\Component\Yaml\Yaml;
11
use EllipseSynergie\LocaleToYaml\Exceptions\FileNotFoundException;
12
use Symfony\Component\Yaml\Exception\DumpException;
13
14
/**
15
 * Class ExportCommand
16
 * @package EllipseSynergie\LocaleToYaml\Commands
17
 */
18
class ExportCommand extends Command
19
{
20
    /**
21
     */
22 3
    protected function configure()
23
    {
24 3
        $this->setName('lang:export-to-yaml')
25 3
            ->setDescription('Export locale file to Yaml.')
26 3
            ->setHelp("This command allows you to export a locale file from PHP to Yaml...")
27 3
            ->addArgument('in', InputArgument::REQUIRED, 'The locale input filename.');
28 3
    }
29
30
    /**
31
     * @param InputInterface $input
32
     * @param OutputInterface $output
33
     */
34 2
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        // Which file need to be converted?
37 2
        $in = $input->getArgument('in');
38
        // Define output file from input one...
39 2
        $out = str_replace('.php', '.yml', $in);
40
41 2
        $output->writeln('Exporting ' . $in . ' to ' . $out);
42
43 2
        if (!file_exists($in)) {
44 1
            throw new FileNotFoundException("Cannot find file " . $in);
45
        }
46
47
        try {
48
49
            // Get content from input file
50 1
            $strings = include($in);
51
            // Output it to Yaml file...
52 1
            file_put_contents($out, Yaml::dump($strings, 100, 4, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
53
54 1
        } catch (DumpException $e) {
55
56
            throw new YamlException("Not able to convert input file to Yaml.");
57
        }
58 1
    }
59
}
60