Completed
Pull Request — master (#11)
by Tristan
02:10
created

ChampionMasteryApi::getTopChampionsMasteries()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 11
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
cc 1
eloc 6
nc 1
nop 3
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 = '/lol/champion-mastery/v3/champion-masteries/by-summoner/{summonerId}';
16
    const API_URL_CHAMPION_MASTERY_BY_CHAMPION_ID = '/lol/champion-mastery/v3/champion-masteries/by-summoner/{summonerId}/by-champion/{championId}';
17
    const API_URL_CHAMPION_MASTERY_SCORE = '/lol/champion-mastery/v3/scores/by-summoner/{summonerId}';
18
19
    /**
20
     * Get all champion mastery entries sorted by number of champion points descending,
21
     *
22
     * @param int $summonerId
23
     *
24
     * @return ApiResult
25
     */
26
    public function getChampionsMasteries($summonerId)
27 1
    {
28
        $url = str_replace('{summonerId}', $summonerId, self::API_URL_CHAMPION_MASTERY_BY_ID);
29 1
30 1
        return $this->callApiUrl($url, [], true);
31 1
    }
32
33 1
    /**
34
     * @param int $summonerId
35
     * @param int $championId
36
     *
37
     * @return ApiResult
38
     */
39
    public function getChampionMastery($summonerId, $championId)
40
    {
41
        $url = str_replace('{summonerId}', $summonerId, self::API_URL_CHAMPION_MASTERY_BY_CHAMPION_ID);
42 1
        $url = str_replace('{championId}', $championId, $url);
43
44 1
        return $this->callApiUrl($url, [], true);
45 1
    }
46
47 1
    /**
48
     * Get a player's total champion mastery score, which is the sum of individual champion mastery levels
49
     *
50
     * @param int $summonerId
51
     *
52
     * @return ApiResult
53
     */
54
    public function getChampionsMasteriesScore($summonerId)
55
    {
56 1
        $url = str_replace('{playerId}', $summonerId, self::API_URL_CHAMPION_MASTERY_SCORE);
57
58 1
        return $this->callApiUrl($url, [], true);
59 1
    }
60
}
61