Completed
Pull Request — develop (#54)
by Steven
19:22 queued 16:17
created

DisableCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 6
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php namespace Magestead\Command\Cache;
2
3
use Magestead\Command\ProcessCommand;
4
use Magestead\Helper\Config;
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
/**
10
 * Class DisableCommand
11
 * @package Magestead\Command\Cache
12
 */
13 View Code Duplication
class DisableCommand extends Command
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...
14
{
15
    protected $_config;
16
    protected $_projectPath;
17
18
    protected function configure()
19
    {
20
        $this->_projectPath = getcwd();
21
        $this->setName("cache:disable");
22
        $this->setDescription("Disable cache types");
23
    }
24
25
    /**
26
     * @param InputInterface $input
27
     * @param OutputInterface $output
28
     * @return ProcessCommand
29
     */
30
    protected function execute(InputInterface $input, OutputInterface $output)
31
    {
32
        $output->writeln('<info>Disabling all cache types</info>');
33
34
        $command  = $this->getCommand(new Config($output));
35
        $pCommand = "vagrant ssh -c '". $command ."'";
36
        return new ProcessCommand($pCommand, $this->_projectPath, $output);
37
    }
38
39
    /**
40
     * @param Config $config
41
     * @return bool|string
42
     */
43
    protected function getCommand(Config $config)
44
    {
45
        $type = $config->type;
0 ignored issues
show
Bug introduced by
The property type does not seem to exist in Magestead\Helper\Config.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
46
        switch ($type) {
47
            case 'magento':
48
                return "cd /var/www/public;../bin/n98-magerun.phar cache:disable";
49
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
50
            case 'magento2':
51
                return "cd /var/www/public;bin/magento cache:disable";
52
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
53
        }
54
55
        return false;
56
    }
57
}