Completed
Push — develop ( 73bd0a...ccb498 )
by Tom
05:04
created

MakeConfigSystemCommand::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 9

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 16
loc 16
rs 9.4285
cc 2
eloc 9
nc 2
nop 2
1
<?php
2
/**
3
 * netz98 magento module
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject of netz98.
8
 * You may be not allowed to change the sources
9
 * without authorization of netz98 new media GmbH.
10
 *
11
 * @copyright  Copyright (c) 1999-2016 netz98 new media GmbH (http://www.netz98.de)
12
 * @author netz98 new media GmbH <[email protected]>
13
 * @category N98
14
 * @package N98\Magento\Command\Developer\Console
15
 */
16
17
namespace N98\Magento\Command\Developer\Console\Config;
18
19
use Symfony\Component\Console\Input\InputArgument;
20
use Symfony\Component\Console\Input\InputInterface;
21
use Symfony\Component\Console\Output\OutputInterface;
22
23 View Code Duplication
class MakeConfigSystemCommand extends AbstractSimpleConfigFileGeneratorCommand
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
{
25
    const CONFIG_FILENAME = 'system.xml';
26
27
    protected function configure()
28
    {
29
        $this
30
            ->setName('make:config:system')
31
            ->addArgument('area', InputArgument::OPTIONAL, 'Area of system.xml file', 'adminhtml')
32
            ->setDescription('Creates a new system.xml file')
33
        ;
34
    }
35
36
    /**
37
     * @param InputInterface  $input
38
     * @param OutputInterface $output
39
     *
40
     * @return int|void
41
     */
42
    protected function execute(InputInterface $input, OutputInterface $output)
43
    {
44
        $selectedArea = $input->getArgument('area');
45
        $relativeConfigFilePath = $this->getRelativeConfigFilePath(self::CONFIG_FILENAME, $selectedArea);
46
47
        if ($this->getCurrentModuleDirectoryReader()->isExist($relativeConfigFilePath)) {
48
            $output->writeln('<warning>File already exists. Skiped generation</warning>');
49
50
            return;
51
        }
52
53
        $referenceConfigFileContent = file_get_contents(__DIR__ . '/_files/reference_system.xml');
54
        $this->getCurrentModuleDirectoryWriter()->writeFile($relativeConfigFilePath, $referenceConfigFileContent);
55
56
        $output->writeln('<info>generated </info><comment>' . $relativeConfigFilePath . '</comment>');
57
    }
58
}
59