Passed
Push — develop ( 676405...acb535 )
by Oguzhan
02:32
created

SearchAlbumCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 44.74 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 4
dl 17
loc 38
ccs 0
cts 17
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
A execute() 17 17 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
 * Created by PhpStorm.
4
 * User: oguzu
5
 * Date: 1-4-2017
6
 * Time: 16:07
7
 */
8
9
namespace Pbxg33k\MusicInfo\Command;
10
11
12
use Pbxg33k\MusicInfo\MusicInfo;
13
use Symfony\Component\Console\Helper\Table;
14
use Symfony\Component\Console\Input\InputArgument;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
class SearchAlbumCommand extends BaseCommand
19
{
20
    const COMMAND_NAME = 'search:album';
21
22
    const COMMAND_DESCRIPTION = 'Search an album on one or more services';
23
24
    /**
25
     * @var MusicInfo
26
     */
27
    protected $musicInfo;
28
29
    protected function configure()
30
    {
31
        $this
32
            ->addArgument('album', InputArgument::REQUIRED, 'Album name')
33
            ->addArgument('service', InputArgument::OPTIONAL, 'Service to use, default to all enabled');
34
35
        parent::configure();
36
    }
37
38 View Code Duplication
    protected function execute(InputInterface $input, OutputInterface $output)
0 ignored issues
show
Duplication introduced by
This method 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...
39
    {
40
        $service = ($input->getArgument('service') != '') ? $input->getArgument('service') : null;
41
42
        $searchResult = $this->musicInfo->doSearch($input->getArgument('album'), 'album', $service);
43
44
        $resultsTable = $this->generateTableForSearchResult($searchResult, [
45
            'id' => 'ID',
46
            'name' => 'Name',
47
            'type' => 'Type',
48
            'image' => 'Image',
49
            'dataSource' => 'Source'
50
        ], new Table($output));
51
52
        $resultsTable->render();
53
54
    }
55
}