Code Duplication    Length = 41-43 lines in 2 locations

src/Magestead/Command/BehatCommand.php 1 location

@@ 13-53 (lines=41) @@
10
 * Class BehatCommand
11
 * @package Magestead\Command
12
 */
13
class BehatCommand extends Command
14
{
15
    protected $_projectPath;
16
17
    protected function configure()
18
    {
19
        $this->_projectPath = getcwd();
20
21
        $this->setName("behat");
22
        $this->setDescription("Run Behat against your project");
23
        $this->addArgument('option', InputArgument::OPTIONAL, 'Add options to run');
24
    }
25
26
    /**
27
     * @param InputInterface $input
28
     * @param OutputInterface $output
29
     * @return mixed
30
     */
31
    protected function execute(InputInterface $input, OutputInterface $output)
32
    {
33
        $option  = $input->getArgument('option');
34
        $command = $this->getCommand(new Config($output), $option);
35
        if (!$command) {
36
            return $output->writeln('<error>Command not available for this application</error>');
37
        }
38
39
        $output->writeln('<info>Running Behat</info>');
40
        $passedCommand = "vagrant ssh -c '". $command ."'";
41
        passthru($passedCommand);
42
    }
43
44
    /**
45
     * @param Config $config
46
     * @param $option
47
     * @return bool|string
48
     */
49
    protected function getCommand(Config $config, $option)
50
    {
51
        $type = $config->type;
52
        switch ($type) {
53
            case 'magento':
54
                return "cd /var/www;bin/behat $option";
55
                break;
56
            case 'magento2':

src/Magestead/Command/PhpspecCommand.php 1 location

@@ 13-55 (lines=43) @@
10
 * Class PhpspecCommand
11
 * @package Magestead\Command
12
 */
13
class PhpspecCommand extends Command
14
{
15
    protected $_projectPath;
16
17
    protected function configure()
18
    {
19
        $this->_projectPath = getcwd();
20
21
        $this->setName("phpspec");
22
        $this->setDescription("Run PHPSpec against your project");
23
        $this->addArgument('option', InputArgument::OPTIONAL, 'Add options to run');
24
    }
25
26
    /**
27
     * @param InputInterface $input
28
     * @param OutputInterface $output
29
     * @return mixed
30
     */
31
    protected function execute(InputInterface $input, OutputInterface $output)
32
    {
33
        $option = $input->getArgument('option');
34
35
        $command = $this->getCommand(new Config($output), $option);
36
        if (!$command) {
37
            return $output->writeln('<error>Command not available for this application</error>');
38
        }
39
40
        $output->writeln('<info>Running PHPSpec</info>');
41
        $passedCommand = "vagrant ssh -c '". $command ."'";
42
        passthru($passedCommand);
43
    }
44
45
    /**
46
     * @param Config $config
47
     * @param $option
48
     * @return bool|string
49
     */
50
    protected function getCommand(Config $config, $option)
51
    {
52
        $type = $config->type;
53
        switch ($type) {
54
            case 'magento':
55
                return "cd /var/www;bin/phpspec $option";
56
                break;
57
            case 'magento2':
58
                return "cd /var/www/public;bin/phpspec $option";