Passed
Push — feature/code-quality ( b3f671...a899ee )
by Oguzhan
05:01 queued 02:25
created

SearchAlbumCommand::setMusicInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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 2
    protected function configure()
30
    {
31 2
        $this
32 2
            ->addArgument('album', InputArgument::REQUIRED, 'Album name')
33 2
            ->addArgument('service', InputArgument::OPTIONAL, 'Service to use, default to all enabled');
34
35 2
        parent::configure();
36 2
    }
37
38 2
    protected function execute(InputInterface $input, OutputInterface $output)
39
    {
40 2
        $service = ($input->getArgument('service') != '') ? $input->getArgument('service') : null;
41
42 2
        $searchResult = $this->musicInfo->doSearch($input->getArgument('album'), 'album', $service);
43
44 2
        $resultsTable = $this->generateTableForSearchResult(
45 2
            $searchResult, [
46 2
            'id' => 'ID',
47 2
            'name' => 'Name',
48 2
            'type' => 'Type',
49 2
            'image' => 'Image',
50
            'dataSource' => 'Source'
51 2
            ], new Table($output)
52 2
        );
53
54 2
        $resultsTable->render();
55
56 2
    }
57
58
    /**
59
     * Set Music info property
60
     *
61
     * @param MusicInfo $musicInfo
62
     */
63 2
    public function setMusicInfo(MusicInfo $musicInfo)
64
    {
65 2
        $this->musicInfo = $musicInfo;
66 2
    }
67
}
68