SectionByIdCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
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