StatusCommand::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
1
<?php namespace Magestead\Command\Index;
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 StatusCommand
11
 * @package Magestead\Command\Index
12
 */
13 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...
14
{
15
    protected $_config;
16
    protected $_projectPath;
17
18
    protected function configure()
19
    {
20
        $this->_projectPath = getcwd();
21
        $this->setName("index:status");
22
        $this->setDescription("Show status of index");
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>Getting index status</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 'magento2':
48
                return "cd /var/www/public;bin/magento indexer:status";
49
        }
50
51
        return false;
52
    }
53
}