ArtistFilter::parseResponse()   B
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
dl 15
loc 15
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 9
nc 3
nop 2
1
<?php
2
3
namespace MusicBrainz\Filters;
4
5
use MusicBrainz\Artist;
6
use MusicBrainz\MusicBrainz;
7
8
/**
9
 * This is the artist filter and it contains
10
 * an array of valid argument types to be used
11
 * when querying the MusicBrainz web service.
12
 */
13
class ArtistFilter extends AbstractFilter implements FilterInterface
14
{
15
    /**
16
     * @var array
17
     */
18
    protected $validArgTypes = array(
19
        'arid',
20
        'artist',
21
        'artistaccent',
22
        'alias',
23
        'begin',
24
        'comment',
25
        'country',
26
        'end',
27
        'ended',
28
        'gender',
29
        'ipi',
30
        'sortname',
31
        'tag',
32
        'type'
33
    );
34
35
    /**
36
     * @return string
37
     */
38
    public function getEntity()
39
    {
40
        return 'artist';
41
    }
42
43
    /**
44
     * @param array       $response
45
     * @param MusicBrainz $brainz
46
     *
47
     * @return Artist[]
48
     */
49 View Code Duplication
    public function parseResponse(array $response, MusicBrainz $brainz)
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...
50
    {
51
        $artists = array();
52
        if (isset($response['artist'])) {
53
            foreach ($response['artist'] as $artist) {
54
                $artists[] = new Artist($artist, $brainz);
55
            }
56
        } elseif (isset($response['artists'])) {
57
            foreach ($response['artists'] as $artist) {
58
                $artists[] = new Artist($artist, $brainz);
59
            }
60
        }
61
62
        return $artists;
63
    }
64
}
65