ChampionApi   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 28
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllChampions() 0 5 1
A getChampionById() 0 6 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