Completed
Pull Request — master (#7)
by Michaël
05:02 queued 01:36
created

ChampionMasteryApi::getChampionsMasteriesScore()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 7
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
crap 1
1
<?php
2
3
namespace LoLApi\Api;
4
5
use LoLApi\Result\ApiResult;
6
7
/**
8
 * Class ChampionMasteryApi
9
 *
10
 * @package LoLApi\Api
11
 * @see     https://developer.riotgames.com/api/methods
12
 */
13
class ChampionMasteryApi extends BaseApi
14
{
15
    const API_URL_CHAMPION_MASTERY_BY_ID = '/championmastery/location/{platformId}/player/{playerId}/champion/{championId}';
16
    const API_URL_CHAMPION_MASTERY_ALL = '/championmastery/location/{platformId}/player/{playerId}/champions';
17
    const API_URL_CHAMPION_MASTERY_SCORE = '/championmastery/location/{platformId}/player/{playerId}/score';
18
    const API_URL_CHAMPION_MASTERY_TOP = '/championmastery/location/{platformId}/player/{playerId}/topchampions';
19
20
    /**
21
     * @param int $platformId
22
     * @param int $championId
23
     * @param int $playerId
24
     *
25
     * @return ApiResult
26
     */
27 1 View Code Duplication
    public function getChampionMastery($platformId, $championId, $playerId)
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...
28
    {
29 1
        $url = str_replace('{championId}', $championId, self::API_URL_CHAMPION_MASTERY_BY_ID);
30 1
        $url = str_replace('{playerId}', $playerId, $url);
31 1
        $url = str_replace('{platformId}', $platformId, $url);
32
33 1
        return $this->callApiUrl($url, []);
34
    }
35
36
    /**
37
     * @param int $platformId
38
     * @param int $playerId
39
     *
40
     * @return ApiResult
41
     */
42 1 View Code Duplication
    public function getChampionsMasteries($platformId, $playerId)
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...
43
    {
44 1
        $url = str_replace('{playerId}', $playerId, self::API_URL_CHAMPION_MASTERY_ALL);
45 1
        $url = str_replace('{platformId}', $platformId, $url);
46
47 1
        return $this->callApiUrl($url, []);
48
    }
49
50
    /**
51
     * @param int $platformId
52
     * @param int $playerId
53
     *
54
     * @return ApiResult
55
     */
56 1 View Code Duplication
    public function getChampionsMasteriesScore($platformId, $playerId)
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...
57
    {
58 1
        $url = str_replace('{playerId}', $playerId, self::API_URL_CHAMPION_MASTERY_SCORE);
59 1
        $url = str_replace('{platformId}', $platformId, $url);
60
61 1
        return $this->callApiUrl($url, []);
62
    }
63
64
    /**
65
     * @param int $platformId
66
     * @param int $playerId
67
     * @param int $limit
68
     *
69
     * @return ApiResult
70
     */
71 1 View Code Duplication
    public function getTopChampionsMasteries($platformId, $playerId, $limit = 3)
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...
72
    {
73 1
        $url = str_replace('{playerId}', $playerId, self::API_URL_CHAMPION_MASTERY_TOP);
74 1
        $url = str_replace('{platformId}', $platformId, $url);
75
76 1
        $queryParameters = [];
77
78 1
        $queryParameters['count'] = (int) $limit;
79
80 1
        return $this->callApiUrl($url, array_filter($queryParameters));
81
    }
82
}
83