Code Duplication    Length = 40-46 lines in 2 locations

src/Command/SearchAlbumCommand.php 1 location

@@ 18-57 (lines=40) @@
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
    protected function execute(InputInterface $input, OutputInterface $output)
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(
45
            $searchResult, [
46
            'id' => 'ID',
47
            'name' => 'Name',
48
            'type' => 'Type',
49
            'image' => 'Image',
50
            'dataSource' => 'Source'
51
            ], new Table($output)
52
        );
53
54
        $resultsTable->render();
55
56
    }
57
}
58

src/Command/SearchArtistCommand.php 1 location

@@ 18-63 (lines=46) @@
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
class SearchArtistCommand extends BaseCommand
19
{
20
    const COMMAND_NAME = 'search:artist';
21
22
    const COMMAND_DESCRIPTION = 'Search an artist on one or more services';
23
24
    /**
25
     * @var MusicInfo
26
     */
27
    protected $musicInfo;
28
29
    protected function configure()
30
    {
31
        $this
32
            ->addArgument('artist', InputArgument::REQUIRED, 'Artist Name')
33
            ->addArgument('service', InputArgument::OPTIONAL, 'Service to use, default to all enabled', null);
34
35
        parent::configure();
36
    }
37
38
    /**
39
     * @param InputInterface  $input
40
     * @param OutputInterface $output
41
     *
42
     * @return void
43
     */
44
    protected function execute(InputInterface $input, OutputInterface $output)
45
    {
46
        $service = ($input->getArgument('service') != '') ? $input->getArgument('service') : null;
47
48
        $searchResults = $this->musicInfo->doSearch($input->getArgument('artist'), 'artist', $service);
49
50
        $resultsTable = $this->generateTableForSearchResult(
51
            $searchResults, [
52
            'id'    => 'ID',
53
            'name'  => 'Name',
54
            'image' => 'Image URL',
55
            'type'  => 'Type',
56
            'dataSource' => 'Source',
57
            'uri'   => 'URL'
58
            ], new Table($output)
59
        );
60
61
        $resultsTable->render();
62
    }
63
}
64