Status::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
namespace LimeSoda\Ess\M2ePro\Channel;
4
5
use N98\Magento\Command\AbstractMagentoCommand;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
class Status extends AbstractMagentoCommand
11
{
12
    const EXTENSION_NAME = 'Ess_M2ePro';
13
    
14
    protected function configure()
15
    {
16
      $this
17
          ->setName('ls:ess:m2epro:channel:status')
18
          ->addArgument('name', InputArgument::REQUIRED, 'Channel name')
19
          ->addArgument('status', InputArgument::REQUIRED, 'Channel status')
20
          ->setDescription('Sets the channel status')
21
          ->setHelp(
22
              <<<EOT
23
              Sets the channel status for Ess_M2ePro. The extension has to be installed and enabled.
24
EOT
25
              );
26
          
27
      ;
28
    }
29
30
   /**
31
    * @param \Symfony\Component\Console\Input\InputInterface $input
32
    * @param \Symfony\Component\Console\Output\OutputInterface $output
33
    * @return int|void
34
    */
35
    protected function execute(InputInterface $input, OutputInterface $output)
36
    {
37
        $this->detectMagento($output);
38
        if ($this->initMagento()) {
39 View Code Duplication
           if (\Mage::helper('core')->isModuleEnabled(self::EXTENSION_NAME) === false) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
40
               throw new \Exception("Extension '" . self::EXTENSION_NAME ."' is not installed.");
41
           } 
42
            
43
           $name = strip_tags($input->getArgument('name'));
44
           $status = intval(strip_tags($input->getArgument('status')));
45
           
46
           \Mage::helper('M2ePro/Module')->getConfig()->setGroupValue('/component/' . $name . '/', 'mode', $status);
47
           
48
           $output->writeln("Set '" . $name . "' channel status."); 
49
        }
50
    }
51
} 
52