SectionByIdCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 7
dl 36
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 12 12 1
A execute() 13 13 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
namespace Stp\SndApi\News\Command;
4
5
use SoapBox\Formatter\Formatter;
6
use Stp\SndApi\Common\Command\BaseCommand;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11 View Code Duplication
class SectionByIdCommand 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...
12
{
13
    use NewsClientCommandTrait;
14
15
    protected function configure()
16
    {
17
        parent::configure();
18
19
        $this
20
            ->setName('news:section:id')
21
            ->addArgument(
22
                'id',
23
                InputArgument::REQUIRED,
24
                'Section ID'
25
            );
26
    }
27
28
    /**
29
     * @param InputInterface $input
30
     * @param OutputInterface $output
31
     * @return int
32
     */
33
    protected function execute(InputInterface $input, OutputInterface $output)
34
    {
35
        $newsClient = $this->getNewsClient($input);
36
37
        $sectionId = $input->getArgument('id');
38
39
        $result = $newsClient->getSectionById($sectionId);
40
        $formatter = Formatter::make($result, Formatter::ARR);
41
42
        $output->writeln($formatter->toYaml());
43
44
        return 0;
45
    }
46
}
47