Completed
Push — master ( 7af315...01acd0 )
by Hannah
11:56
created

InfoCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 100 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 2
cbo 4
dl 35
loc 35
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 6 6 1
A execute() 19 19 2

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 Geekish\Crap\Command;
4
5
use Symfony\Component\Console\Input\InputInterface;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
/**
10
 * Class UnaliasCommand
11
 * @package Geekish\Crap\Command
12
 */
13 View Code Duplication
final class InfoCommand extends BaseCommand
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
14
{
15
    /**
16
     * @inheritDoc
17
     */
18
    protected function configure()
19
    {
20
        $this->setName("info");
21
        $this->setDescription("Get a single alias.");
22
        $this->addArgument("alias", InputArgument::REQUIRED, "Package alias");
23
    }
24
25
    /**
26
     * @inheritDoc
27
     */
28
    protected function execute(InputInterface $input, OutputInterface $output)
29
    {
30
        $alias = $input->getArgument("alias");
31
32
        if (!$this->helper->hasAlias($alias)) {
33
            $output->writeln(sprintf(
34
                "<success>Alias `%s` does not exist.</success>",
35
                $alias
36
            ));
37
38
            return 1;
39
        }
40
41
        $package = $this->helper->getAlias($alias);
42
43
        $output->writeln(sprintf("Alias `%s` is set to: <comment>%s</comment>", $alias, $package));
44
45
        return 0;
46
    }
47
}
48