SearchCollectionCommand::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 2
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 SearchCollectionCommand 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:search:collection')
21
            ->addArgument(
22
                'ids',
23
                InputArgument::REQUIRED | InputArgument::IS_ARRAY,
24
                'Content IDs'
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
        $contentIds = $input->getArgument('ids');
38
39
        $result = $newsClient->searchByCollection($contentIds);
40
        $formatter = Formatter::make($result, Formatter::ARR);
41
42
        $output->writeln($formatter->toYaml());
43
44
        return 0;
45
    }
46
}
47