HookListCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 8 8 1
A execute() 8 8 1
A showTitle() 4 4 1
A getConsoleOutPutter() 4 4 1
A getHookService() 4 4 1

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
/**
4
 * Created by Graham Owens ([email protected])
5
 * Company: PartFire Ltd (www.partfire.co.uk)
6
 * Console: Discovery
7
 *
8
 * User:    gra
9
 * Date:    13/01/17
10
 * Time:    16:23
11
 * Project: PartFire MangoPay Bundle
12
 * File:    HookListCommand.php
13
 *
14
 **/
15
16
17
namespace PartFire\MangoPayBundle\Command;
18
19
use Fruitful\IdentityCheckBundle\Entity\IdentityCheck;
20
use Fruitful\IdentityCheckBundle\Entity\Repository\IdentityCheckFactoryRepository;
21
use Fruitful\IdentityCheckBundle\Event\IdentityCheckUpdateEvent;
22
use PartFire\CommonBundle\Services\Output\Cli\ConsoleOutput;
23
use PartFire\MangoPayBundle\Services\Hook;
24
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
25
use Symfony\Component\Console\Input\InputArgument;
26
use Symfony\Component\Console\Input\InputDefinition;
27
use Symfony\Component\Console\Input\InputInterface;
28
use Symfony\Component\Console\Input\InputOption;
29
use Symfony\Component\Console\Output\OutputInterface;
30
use Symfony\Component\EventDispatcher\EventDispatcher;
31
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
32
33 View Code Duplication
class HookListCommand extends ContainerAwareCommand
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...
34
{
35
36
    private $output;
37
38
    protected function configure()
39
    {
40
        $this
41
            ->setName('partfire:mangopay:hook-list')
42
            ->setDescription('Shows all hooks registered in Mango')
43
            ;
44
45
    }
46
47
    protected function execute(InputInterface $input, OutputInterface $output)
48
    {
49
        $this->output = $this->getConsoleOutPutter();
50
        $this->output->setOutputer($output);
51
52
        $this->output->info("Listing all hooks with MangoPay");
53
        var_dump($this->getHookService()->list());
0 ignored issues
show
Security Debugging Code introduced by
var_dump($this->getHookService()->list()); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
54
    }
55
56
    private function showTitle($title)
57
    {
58
        $this->output->info(str_pad(" " . $title . " ", 80, "-", STR_PAD_BOTH));
59
    }
60
61
    private function getConsoleOutPutter() : ConsoleOutput
62
    {
63
        return $this->getContainer()->get('partfire_common.output_console');
64
    }
65
66
    private function getHookService() : Hook
67
    {
68
        return $this->getContainer()->get('part_fire_mango_pay.services.hook');
69
    }
70
71
}