StatusCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 9.4285
c 0
b 0
f 0
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\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
/**
11
 * Class StatusCommand
12
 * @package Magestead\Command\Cache
13
 */
14 View Code Duplication
class StatusCommand 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...
15
{
16
    protected $_config;
17
    protected $_projectPath;
18
19
    protected function configure()
20
    {
21
        $this->_projectPath = getcwd();
22
        $this->setName("cache:status");
23
        $this->setDescription("Checks cache status");
24
    }
25
26
    /**
27
     * @param InputInterface $input
28
     * @param OutputInterface $output
29
     * @return ProcessCommand
30
     */
31
    protected function execute(InputInterface $input, OutputInterface $output)
32
    {
33
        $output->writeln('<info>Checking cache status</info>');
34
35
        $command  = $this->getCommand(new Config($output));
36
        $pCommand = "vagrant ssh -c '". $command ."'";
37
        return new ProcessCommand($pCommand, $this->_projectPath, $output);
38
    }
39
40
    /**
41
     * @param Config $config
42
     * @return bool|string
43
     */
44
    protected function getCommand(Config $config)
45
    {
46
        $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...
47
        switch ($type) {
48
            case 'magento':
49
                return "cd /var/www/public;../bin/n98-magerun.phar cache:list";
50
            case 'magento2':
51
                return "cd /var/www/public;bin/magento cache:status";
52
        }
53
54
        return false;
55
    }
56
}