Status   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 7.14 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 3
loc 42
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 15 1
A execute() 3 16 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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