Code Duplication    Length = 46-46 lines in 5 locations

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

@@ 9-54 (lines=46) @@
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class CleanCommand extends Command
10
{
11
    protected $_config;
12
    protected $_projectPath;
13
14
    protected function configure()
15
    {
16
        $this->_projectPath = getcwd();
17
        $this->setName("cache:clean");
18
        $this->setDescription("Cleans cache types");
19
    }
20
21
    /**
22
     * @param InputInterface $input
23
     * @param OutputInterface $output
24
     * @return ProcessCommand
25
     */
26
    protected function execute(InputInterface $input, OutputInterface $output)
27
    {
28
        $output->writeln('<info>Cleaning all cache types</info>');
29
30
        $command = $this->getCommand(new Config($output));
31
        $passedCommand = "vagrant ssh -c '". $command ."'";
32
        return new ProcessCommand($passedCommand, $this->_projectPath, $output);
33
    }
34
35
    /**
36
     * @param Config $config
37
     * @return bool|string
38
     */
39
    protected function getCommand(Config $config)
40
    {
41
        $type = $config->type;
42
        switch ($type) {
43
            case 'magento':
44
                // todo add magerun commands
45
                return "";
46
                break;
47
            case 'magento2':
48
                return "cd /var/www/public;bin/magento cache:clean";
49
                break;
50
        }
51
52
        return false;
53
    }
54
}

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

@@ 9-54 (lines=46) @@
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class DisableCommand extends Command
10
{
11
    protected $_config;
12
    protected $_projectPath;
13
14
    protected function configure()
15
    {
16
        $this->_projectPath = getcwd();
17
        $this->setName("cache:disable");
18
        $this->setDescription("Disable cache types");
19
    }
20
21
    /**
22
     * @param InputInterface $input
23
     * @param OutputInterface $output
24
     * @return ProcessCommand
25
     */
26
    protected function execute(InputInterface $input, OutputInterface $output)
27
    {
28
        $output->writeln('<info>Disabling all cache types</info>');
29
30
        $command = $this->getCommand(new Config($output));
31
        $passedCommand = "vagrant ssh -c '". $command ."'";
32
        return new ProcessCommand($passedCommand, $this->_projectPath, $output);
33
    }
34
35
    /**
36
     * @param Config $config
37
     * @return bool|string
38
     */
39
    protected function getCommand(Config $config)
40
    {
41
        $type = $config->type;
42
        switch ($type) {
43
            case 'magento':
44
                // todo add magerun commands
45
                return "";
46
                break;
47
            case 'magento2':
48
                return "cd /var/www/public;bin/magento cache:disable";
49
                break;
50
        }
51
52
        return false;
53
    }
54
}

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

@@ 9-54 (lines=46) @@
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class EnableCommand extends Command
10
{
11
    protected $_config;
12
    protected $_projectPath;
13
14
    protected function configure()
15
    {
16
        $this->_projectPath = getcwd();
17
        $this->setName("cache:enable");
18
        $this->setDescription("Enable cache types");
19
    }
20
21
    /**
22
     * @param InputInterface $input
23
     * @param OutputInterface $output
24
     * @return ProcessCommand
25
     */
26
    protected function execute(InputInterface $input, OutputInterface $output)
27
    {
28
        $output->writeln('<info>Enabling all cache types</info>');
29
30
        $command = $this->getCommand(new Config($output));
31
        $passedCommand = "vagrant ssh -c '". $command ."'";
32
        return new ProcessCommand($passedCommand, $this->_projectPath, $output);
33
    }
34
35
    /**
36
     * @param Config $config
37
     * @return bool|string
38
     */
39
    protected function getCommand(Config $config)
40
    {
41
        $type = $config->type;
42
        switch ($type) {
43
            case 'magento':
44
                // todo add magerun commands
45
                return "";
46
                break;
47
            case 'magento2':
48
                return "cd /var/www/public;bin/magento cache:enable";
49
                break;
50
        }
51
52
        return false;
53
    }
54
}

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

@@ 9-54 (lines=46) @@
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class FlushCommand extends Command
10
{
11
    protected $_config;
12
    protected $_projectPath;
13
14
    protected function configure()
15
    {
16
        $this->_projectPath = getcwd();
17
        $this->setName("cache:flush");
18
        $this->setDescription("Flushes cache storage used by cache types");
19
    }
20
21
    /**
22
     * @param InputInterface $input
23
     * @param OutputInterface $output
24
     * @return ProcessCommand
25
     */
26
    protected function execute(InputInterface $input, OutputInterface $output)
27
    {
28
        $output->writeln('<info>Flushing cache storage</info>');
29
30
        $command = $this->getCommand(new Config($output));
31
        $passedCommand = "vagrant ssh -c '". $command ."'";
32
        return new ProcessCommand($passedCommand, $this->_projectPath, $output);
33
    }
34
35
    /**
36
     * @param Config $config
37
     * @return bool|string
38
     */
39
    protected function getCommand(Config $config)
40
    {
41
        $type = $config->type;
42
        switch ($type) {
43
            case 'magento':
44
                // todo add magerun commands
45
                return "";
46
                break;
47
            case 'magento2':
48
                return "cd /var/www/public;bin/magento cache:flush";
49
                break;
50
        }
51
52
        return false;
53
    }
54
}

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

@@ 9-54 (lines=46) @@
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class StatusCommand extends Command
10
{
11
    protected $_config;
12
    protected $_projectPath;
13
14
    protected function configure()
15
    {
16
        $this->_projectPath = getcwd();
17
        $this->setName("cache:status");
18
        $this->setDescription("Checks cache status");
19
    }
20
21
    /**
22
     * @param InputInterface $input
23
     * @param OutputInterface $output
24
     * @return ProcessCommand
25
     */
26
    protected function execute(InputInterface $input, OutputInterface $output)
27
    {
28
        $output->writeln('<info>Checking cache status</info>');
29
30
        $command = $this->getCommand(new Config($output));
31
        $passedCommand = "vagrant ssh -c '". $command ."'";
32
        return new ProcessCommand($passedCommand, $this->_projectPath, $output);
33
    }
34
35
    /**
36
     * @param Config $config
37
     * @return bool|string
38
     */
39
    protected function getCommand(Config $config)
40
    {
41
        $type = $config->type;
42
        switch ($type) {
43
            case 'magento':
44
                // todo add magerun commands
45
                return "";
46
                break;
47
            case 'magento2':
48
                return "cd /var/www/public;bin/magento cache:status";
49
                break;
50
        }
51
52
        return false;
53
    }
54
}