SearchTrackCommand::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18

Duplication

Lines 18
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 18
loc 18
ccs 0
cts 13
cp 0
rs 9.6666
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 6
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: oguzu
5
 * Date: 29-3-2017
6
 * Time: 16:11
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 SearchTrackCommand extends BaseCommand
19
{
20
    const COMMAND_NAME = 'search:track';
21
22
    const COMMAND_DESCRIPTION = 'Search a track on one or more services';
23
24
    /**
25
     * @var MusicInfo
26
     */
27
    protected $musicInfo;
28
29
    protected function configure()
30
    {
31
        $this
32
            ->addArgument('track', InputArgument::REQUIRED, 'Artist Name')
33
            ->addArgument('service', InputArgument::OPTIONAL, 'Service to use, default to all enabled');
34
35
        parent::configure(); // TODO: Change the autogenerated stub
36
    }
37
38 View Code Duplication
    public 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
        $searchResults = $this->musicInfo->doSearch($input->getArgument('track'), 'track', $service);
43
44
        $resultsTable = $this->generateTableForSearchResult($searchResults, [
45
            'id'    => 'ID',
46
            'name'  => 'Name',
47
            'image' => 'Image URL',
48
            'length'=> 'Duration',
49
            'type'  => 'Type',
50
            'dataSource' => 'Source',
51
            'uri'   => 'URL'
52
        ], new Table($output));
53
54
        $resultsTable->render();
55
    }
56
}