Code Duplication    Length = 42-45 lines in 7 locations

src/Magestead/Command/Cache/CleanCommand.php 1 location

@@ 13-57 (lines=45) @@
10
 * Class CleanCommand
11
 * @package Magestead\Command\Cache
12
 */
13
class CleanCommand extends Command
14
{
15
    protected $_config;
16
    protected $_projectPath;
17
18
    protected function configure()
19
    {
20
        $this->_projectPath = getcwd();
21
        $this->setName("cache:clean");
22
        $this->setDescription("Cleans 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>Cleaning 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;
46
        switch ($type) {
47
            case 'magento':
48
                return "cd /var/www/public;../bin/n98-magerun.phar cache:clean";
49
                break;
50
            case 'magento2':
51
                return "cd /var/www/public;bin/magento cache:clean";
52
                break;
53
        }
54
55
        return false;
56
    }
57
}

src/Magestead/Command/Cache/DisableCommand.php 1 location

@@ 13-57 (lines=45) @@
10
 * Class DisableCommand
11
 * @package Magestead\Command\Cache
12
 */
13
class DisableCommand extends Command
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;
46
        switch ($type) {
47
            case 'magento':
48
                return "cd /var/www/public;../bin/n98-magerun.phar cache:disable";
49
                break;
50
            case 'magento2':
51
                return "cd /var/www/public;bin/magento cache:disable";
52
                break;
53
        }
54
55
        return false;
56
    }
57
}

src/Magestead/Command/Cache/EnableCommand.php 1 location

@@ 13-57 (lines=45) @@
10
 * Class EnableCommand
11
 * @package Magestead\Command\Cache
12
 */
13
class EnableCommand extends Command
14
{
15
    protected $_config;
16
    protected $_projectPath;
17
18
    protected function configure()
19
    {
20
        $this->_projectPath = getcwd();
21
        $this->setName("cache:enable");
22
        $this->setDescription("Enable 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>Enabling 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;
46
        switch ($type) {
47
            case 'magento':
48
                return "cd /var/www/public;../bin/n98-magerun.phar cache:enable";
49
                break;
50
            case 'magento2':
51
                return "cd /var/www/public;bin/magento cache:enable";
52
                break;
53
        }
54
55
        return false;
56
    }
57
}

src/Magestead/Command/Cache/FlushCommand.php 1 location

@@ 13-57 (lines=45) @@
10
 * Class FlushCommand
11
 * @package Magestead\Command\Cache
12
 */
13
class FlushCommand extends Command
14
{
15
    protected $_config;
16
    protected $_projectPath;
17
18
    protected function configure()
19
    {
20
        $this->_projectPath = getcwd();
21
        $this->setName("cache:flush");
22
        $this->setDescription("Flushes cache storage used by 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>Flushing cache storage</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;
46
        switch ($type) {
47
            case 'magento':
48
                return "cd /var/www/public;../bin/n98-magerun.phar cache:flush";
49
                break;
50
            case 'magento2':
51
                return "cd /var/www/public;bin/magento cache:flush";
52
                break;
53
        }
54
55
        return false;
56
    }
57
}

src/Magestead/Command/Cache/StatusCommand.php 1 location

@@ 13-57 (lines=45) @@
10
 * Class StatusCommand
11
 * @package Magestead\Command\Cache
12
 */
13
class StatusCommand extends Command
14
{
15
    protected $_config;
16
    protected $_projectPath;
17
18
    protected function configure()
19
    {
20
        $this->_projectPath = getcwd();
21
        $this->setName("cache:status");
22
        $this->setDescription("Checks cache status");
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>Checking cache 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;
46
        switch ($type) {
47
            case 'magento':
48
                return "cd /var/www/public;../bin/n98-magerun.phar cache:list";
49
                break;
50
            case 'magento2':
51
                return "cd /var/www/public;bin/magento cache:status";
52
                break;
53
        }
54
55
        return false;
56
    }
57
}

src/Magestead/Command/Index/InfoCommand.php 1 location

@@ 13-57 (lines=45) @@
10
 * Class InfoCommand
11
 * @package Magestead\Command\Index
12
 */
13
class InfoCommand extends Command
14
{
15
    protected $_config;
16
    protected $_projectPath;
17
18
    protected function configure()
19
    {
20
        $this->_projectPath = getcwd();
21
        $this->setName("index:info");
22
        $this->setDescription("Show available indexes");
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 information</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;
46
        switch ($type) {
47
            case 'magento':
48
                return "cd /var/www/public;../bin/n98-magerun.phar index:list";
49
                break;
50
            case 'magento2':
51
                return "cd /var/www/public;bin/magento indexer:info";
52
                break;
53
        }
54
55
        return false;
56
    }
57
}

src/Magestead/Command/Index/StatusCommand.php 1 location

@@ 13-54 (lines=42) @@
10
 * Class StatusCommand
11
 * @package Magestead\Command\Index
12
 */
13
class StatusCommand extends Command
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;
46
        switch ($type) {
47
            case 'magento2':
48
                return "cd /var/www/public;bin/magento indexer:status";
49
                break;
50
        }
51
52
        return false;
53
    }
54
}