MatchApi::getMatchListByAccountId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 0
cts 0
cp 0
rs 9.7666
c 0
b 0
f 0
cc 1
nc 1
nop 8
crap 2

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace LoLApi\Api;
4
5
use LoLApi\Result\ApiResult;
6
7
/**
8
 * Class MatchApi
9
 *
10
 * @package LoLApi\Api
11
 * @see     https://developer.riotgames.com/api-methods/
12
 */
13
class MatchApi extends BaseApi
14
{
15
    const API_URL_MATCH_BY_ID = '/lol/match/v3/matches/{matchId}';
16
    const API_URL_MATCH_LIST_BY_ACCOUNT = '/lol/match/v3/matchlists/by-account/{accountId}';
17
    const API_URL_RECENT_MATCH_LIST_BY_ACCOUNT = '/lol/match/v3/matchlists/by-account/{accountId}/recent';
18
    const API_URL_TIMELINES_BY_MATCH_ID = '/lol/match/v3/timelines/by-match/{matchId}';
19
    const API_URL_MATCH_ID_BY_TOURNAMENT_CODE = '/lol/match/v3/matches/by-tournament-code/{tournamentCode}/ids';
20
    const API_URL_MATCH_BY_MATCH_ID_AND_TOURNAMENT_CODE = '/lol/match/v3/matches/{matchId}/by-tournament-code/{tournamentCode}';
21
22
    /**
23 1
     * @param int $matchId
24
     *
25 1
     * @return ApiResult
26 1
     */
27
    public function getMatchByMatchId($matchId)
28 1
    {
29
        $url = str_replace('{matchId}', $matchId, self::API_URL_MATCH_BY_ID);
30 1
31
        return $this->callApiUrl($url, []);
32
    }
33
34
    /**
35
     * @param int   $accountId
36
     * @param array $championIds
37
     * @param array $rankedQueues
38
     * @param array $seasons
39
     * @param int   $beginTime
40
     * @param int   $endTime
41
     * @param int   $beginIndex
42
     * @param int   $endIndex
43
     *
44
     * @return ApiResult
45
     */
46
    public function getMatchListByAccountId($accountId, array $championIds = [], array $rankedQueues = [], array $seasons = [], $beginTime = null, $endTime = null, $beginIndex = null, $endIndex = null)
47
    {
48
        $url             = str_replace('{accountId}', $accountId, self::API_URL_MATCH_LIST_BY_ACCOUNT);
49
        $queryParameters = [];
50
51
        $queryParameters['championIds']  = implode(',', $championIds);
52
        $queryParameters['rankedQueues'] = implode(',', $rankedQueues);
53
        $queryParameters['seasons']      = implode(',', $seasons);
54
        $queryParameters['beginTime']    = $beginTime;
55
        $queryParameters['endTime']      = $endTime;
56
        $queryParameters['beginIndex']   = $beginIndex;
57
        $queryParameters['endIndex']     = $endIndex;
58
59
        return $this->callApiUrl($url, array_filter($queryParameters));
60
    }
61
62
63
    /**
64
     * Get matchlist for last 20 matches played on given account ID and platform ID.
65
     *
66
     * @throws \Exception
67
     */
68
    public function getLastMatchlistByAccountId()
69
    {
70
        throw new \Exception("Method not implemented yet");
71
    }
72
73
    /**
74
     * Get match timeline by match ID.
75
     *
76
     * @throws \Exception
77
     */
78
    public function getTimelineByMatchId()
79
    {
80
        throw new \Exception("Method not implemented yet");
81
    }
82
83
    /**
84
     * Get match IDs by tournament code.
85
     *
86
     * @param string $tournamentCode
87
     *
88
     * @throws \Exception
89
     */
90
    public function getMatchIdByTournamentCode($tournamentCode)
0 ignored issues
show
Unused Code introduced by
The parameter $tournamentCode is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
91
    {
92
        throw new \Exception("Method not implemented yet");
93
    }
94
95
    /**
96
     * Get match by match ID and tournament code.
97
     *
98
     * @param int    $matchId
99
     * @param string $tournamentCode
100
     *
101
     * @throws \Exception
102
     */
103
    public function getMatchByMatchIdAndTournamentCode($matchId, $tournamentCode)
0 ignored issues
show
Unused Code introduced by
The parameter $matchId is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $tournamentCode is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
104
    {
105
        throw new \Exception("Method not implemented yet");
106
    }
107
}
108