GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 625674...909c28 )
by Christian
01:42
created

ChartService::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Core23\LastFm\Service;
13
14
use Core23\LastFm\Client\ApiClientInterface;
15
use Core23\LastFm\Model\ArtistInfo;
16
use Core23\LastFm\Model\Song;
17
use Core23\LastFm\Model\Tag;
18
use Core23\LastFm\Util\ApiHelper;
19
20
final class ChartService implements ChartServiceInterface
21
{
22
    /**
23
     * @var ApiClientInterface
24
     */
25
    private $client;
26
27
    /**
28
     * @param ApiClientInterface $client
29
     */
30
    public function __construct(ApiClientInterface $client)
31
    {
32
        $this->client = $client;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 View Code Duplication
    public function getTopArtists(int $limit = 50, int $page = 1): array
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
        $response = $this->client->unsignedCall('chart.getTopArtists', [
41
            'limit' => $limit,
42
            'page'  => $page,
43
        ]);
44
45
        if (!isset($response['artists']['artist'])) {
46
            return [];
47
        }
48
49
        return ApiHelper::mapList(
50
            static function ($data) {
51
                return ArtistInfo::fromApi($data);
52
            },
53
            $response['artists']['artist']
54
        );
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60 View Code Duplication
    public function getTopTags(int $limit = 50, int $page = 1): array
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...
61
    {
62
        $response = $this->client->unsignedCall('chart.getTopTags', [
63
            'limit' => $limit,
64
            'page'  => $page,
65
        ]);
66
67
        if (!isset($response['tags']['tag'])) {
68
            return [];
69
        }
70
71
        return ApiHelper::mapList(
72
            static function ($data) {
73
                return Tag::fromApi($data);
74
            },
75
            $response['tags']['tag']
76
        );
77
    }
78
79
    /**
80
     * {@inheritdoc}
81
     */
82 View Code Duplication
    public function getTopTracks(int $limit = 50, int $page = 1): array
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...
83
    {
84
        $response = $this->client->unsignedCall('chart.getTopTracks', [
85
            'limit' => $limit,
86
            'page'  => $page,
87
        ]);
88
89
        if (!isset($response['tracks']['track'])) {
90
            return [];
91
        }
92
93
        return ApiHelper::mapList(
94
            static function ($data) {
95
                return Song::fromApi($data);
96
            },
97
            $response['tracks']['track']
98
        );
99
    }
100
}
101