ChampionApi::getAllChampions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace LoLApi\Api;
4
5
use LoLApi\Result\ApiResult;
6
7
/**
8
 * Class ChampionApi
9
 *
10
 * @package LoLApi\Api
11
 * @see     https://developer.riotgames.com/api-methods/
12
 */
13
class ChampionApi extends BaseApi
14
{
15
    const API_URL_CHAMPIONS_ALL = '/lol/platform/v3/champions';
16
    const API_URL_CHAMPION_BY_ID = '/lol/platform/v3/champions/{id}';
17
18
    /**
19
     * @param bool $onlyFreeToPlay
20
     *
21
     * @return ApiResult
22
     */
23 1
    public function getAllChampions($onlyFreeToPlay = false)
24
    {
25
        // The json_encode trick is here to change the boolean to a string representation of the boolean
26 1
        return $this->callApiUrl(self::API_URL_CHAMPIONS_ALL, ['freeToPlay' => json_encode($onlyFreeToPlay)]);
27
    }
28
29
    /**
30
     * @param int $championId
31
     *
32
     * @return ApiResult
33
     */
34 1
    public function getChampionById($championId)
35
    {
36 1
        $url = str_replace('{id}', $championId, self::API_URL_CHAMPION_BY_ID);
37
38 1
        return $this->callApiUrl($url, []);
39
    }
40
}
41