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
|
|
View Code Duplication |
public function getChampionMastery($platformId, $championId, $playerId) |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
$url = str_replace('{championId}', $championId, self::API_URL_CHAMPION_MASTERY_BY_ID); |
30
|
|
|
$url = str_replace('{playerId}', $playerId, $url); |
31
|
|
|
$url = str_replace('{platformId}', $platformId, $url); |
32
|
|
|
|
33
|
|
|
return $this->callApiUrl($url, []); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param int $platformId |
38
|
|
|
* @param int $playerId |
39
|
|
|
* |
40
|
|
|
* @return ApiResult |
41
|
|
|
*/ |
42
|
|
View Code Duplication |
public function getChampionsMasteries($platformId, $playerId) |
|
|
|
|
43
|
|
|
{ |
44
|
|
|
$url = str_replace('{playerId}', $playerId, self::API_URL_CHAMPION_MASTERY_ALL); |
45
|
|
|
$url = str_replace('{platformId}', $platformId, $url); |
46
|
|
|
|
47
|
|
|
return $this->callApiUrl($url, []); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param int $platformId |
52
|
|
|
* @param int $playerId |
53
|
|
|
* |
54
|
|
|
* @return ApiResult |
55
|
|
|
*/ |
56
|
|
View Code Duplication |
public function getChampionsMasteriesScore($platformId, $playerId) |
|
|
|
|
57
|
|
|
{ |
58
|
|
|
$url = str_replace('{playerId}', $playerId, self::API_URL_CHAMPION_MASTERY_SCORE); |
59
|
|
|
$url = str_replace('{platformId}', $platformId, $url); |
60
|
|
|
|
61
|
|
|
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
|
|
View Code Duplication |
public function getTopChampionsMasteries($platformId, $playerId, $limit = 3) |
|
|
|
|
72
|
|
|
{ |
73
|
|
|
$url = str_replace('{playerId}', $playerId, self::API_URL_CHAMPION_MASTERY_TOP); |
74
|
|
|
$url = str_replace('{platformId}', $platformId, $url); |
75
|
|
|
|
76
|
|
|
$queryParameters = []; |
77
|
|
|
|
78
|
|
|
$queryParameters['count'] = (int) $limit; |
79
|
|
|
|
80
|
|
|
return $this->callApiUrl($url, array_filter($queryParameters)); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
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.