Completed
Push — master ( bd8ce9...10c692 )
by Michaël
56s
created

ChampionMasteryApi   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 70
Duplicated Lines 47.14 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 33
loc 70
ccs 19
cts 19
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getChampionMastery() 8 8 1
A getChampionsMasteries() 7 7 1
A getChampionsMasteriesScore() 7 7 1
A getTopChampionsMasteries() 11 11 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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