StaticDataApi::getSummonerSpells()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
crap 1
1
<?php
2
3
namespace LoLApi\Api;
4
5
use LoLApi\Result\ApiResult;
6
7
/**
8
 * Class StaticDataApi
9
 *
10
 * @package LoLApi\Api
11
 * @see     https://developer.riotgames.com/api-methods/
12
 */
13
class StaticDataApi extends BaseApi
14
{
15
    const API_URL_STATIC_DATA_CHAMPIONS = '/lol/static-data/v3/champions';
16
    const API_URL_STATIC_DATA_CHAMPION_BY_ID = '/lol/static-data/v3/champions/{id}';
17
    const API_URL_STATIC_DATA_ITEMS = '/lol/static-data/v3/items';
18
    const API_URL_STATIC_DATA_ITEM_BY_ID = '/lol/static-data/v3/items/{id}';
19
    const API_URL_STATIC_DATA_LANGUAGE_STRINGS = '/lol/static-data/v3/language-strings';
20
    const API_URL_STATIC_DATA_LANGUAGES = '/lol/static-data/v3/languages';
21
    const API_URL_STATIC_DATA_MAP = '/lol/static-data/v3/maps';
22
    const API_URL_STATIC_DATA_MASTERIES = '/lol/static-data/v3/masteries';
23
    const API_URL_STATIC_DATA_MASTERY_BY_ID = '/lol/static-data/v3/masteries/{id}';
24
    const API_URL_STATIC_DATA_REALM = '/lol/static-data/v3/realms';
25
    const API_URL_STATIC_DATA_RUNES = '/lol/static-data/v3/runes';
26
    const API_URL_STATIC_DATA_RUNE_BY_ID = '/lol/static-data/v3/runes/{id}';
27
    const API_URL_STATIC_DATA_SUMMONER_SPELLS = '/lol/static-data/v3/summoner-spells';
28
    const API_URL_STATIC_DATA_SUMMONER_SPELL_BY_ID = '/lol/static-data/v3/summoner-spells/{id}';
29
    const API_URL_STATIC_DATA_VERSIONS = '/lol/static-data/v3/versions';
30
31
    /**
32
     * @param string $locale
33
     * @param string $version
34
     * @param bool   $dataById
35
     * @param array  $champData
36
     *
37
     * @return ApiResult|null
38
     */
39 1
    public function getChampions($locale = null, $version = null, $dataById = false, array $champData = [])
40
    {
41 1
        $queryParameters = $this->handleQueryParametersForLocaleAndVersion($locale, $version, ['dataById' => (string) $dataById, 'champData' => implode(',', $champData)]);
42
43 1
        return $this->callApiUrl(self::API_URL_STATIC_DATA_CHAMPIONS, array_filter($queryParameters));
44
    }
45
46
    /**
47
     * @param int    $championId
48
     * @param string $locale
49
     * @param string $version
50
     * @param array  $champData
51
     *
52
     * @return ApiResult|null
53
     */
54 2
    public function getChampionById($championId, $locale = null, $version = null, array $champData = [])
55
    {
56 2
        $queryParameters = $this->handleQueryParametersForLocaleAndVersion($locale, $version, ['champData' => implode(',', $champData)]);
57
58 2
        return $this->callApiUrl(str_replace('{id}', $championId, self::API_URL_STATIC_DATA_CHAMPION_BY_ID), array_filter($queryParameters));
59
    }
60
61
    /**
62
     * @param string $locale
63
     * @param string $version
64
     *
65
     * @return ApiResult|null
66
     */
67 1
    public function getItems($locale = null, $version = null)
68
    {
69 1
        $queryParameters = $this->handleQueryParametersForLocaleAndVersion($locale, $version);
70
71 1
        return $this->callApiUrl(self::API_URL_STATIC_DATA_ITEMS, array_filter($queryParameters));
72
    }
73
74
    /**
75
     * @param int    $itemId
76
     * @param string $locale
77
     * @param string $version
78
     * @param array  $itemData
79
     *
80
     * @return ApiResult|null
81
     */
82 1
    public function getItemById($itemId, $locale = null, $version = null, array $itemData = [])
83
    {
84 1
        $queryParameters = $this->handleQueryParametersForLocaleAndVersion($locale, $version, ['itemData' => implode(',', $itemData)]);
85
86 1
        return $this->callApiUrl(str_replace('{id}', $itemId, self::API_URL_STATIC_DATA_ITEM_BY_ID), array_filter($queryParameters));
87
    }
88
89
    /**
90
     * @param string $locale
91
     * @param string $version
92
     *
93
     * @return ApiResult|null
94
     */
95 1
    public function getLanguageStrings($locale = null, $version = null)
96
    {
97 1
        $queryParameters = $this->handleQueryParametersForLocaleAndVersion($locale, $version);
98
99 1
        return $this->callApiUrl(self::API_URL_STATIC_DATA_LANGUAGE_STRINGS, array_filter($queryParameters));
100
    }
101
102
    /**
103
     * @return ApiResult|null
104
     */
105 1
    public function getLanguages()
106
    {
107 1
        return $this->callApiUrl(self::API_URL_STATIC_DATA_LANGUAGES, []);
108
    }
109
110
    /**
111
     * @param string $locale
112
     * @param string $version
113
     *
114
     * @return ApiResult|null
115
     */
116 1
    public function getMap($locale = null, $version = null)
117
    {
118 1
        $queryParameters = $this->handleQueryParametersForLocaleAndVersion($locale, $version);
119
120 1
        return $this->callApiUrl(self::API_URL_STATIC_DATA_MAP, array_filter($queryParameters));
121
    }
122
123
    /**
124
     * @param string $locale
125
     * @param string $version
126
     * @param array  $masteryListData
127
     *
128
     * @return ApiResult|null
129
     */
130 1
    public function getMasteries($locale = null, $version = null, array $masteryListData = [])
131
    {
132 1
        $queryParameters = $this->handleQueryParametersForLocaleAndVersion($locale, $version, ['masteryListData' => implode(',', $masteryListData)]);
133
134 1
        return $this->callApiUrl(self::API_URL_STATIC_DATA_MASTERIES, array_filter($queryParameters));
135
    }
136
137
    /**
138
     * @param int    $masteryId
139
     * @param string $locale
140
     * @param string $version
141
     * @param array  $masteryData
142
     *
143
     * @return ApiResult|null
144
     */
145 1
    public function getMasteryById($masteryId, $locale = null, $version = null, array $masteryData = [])
146
    {
147 1
        $queryParameters = $this->handleQueryParametersForLocaleAndVersion($locale, $version, ['masteryData' => implode(',', $masteryData)]);
148
149 1
        return $this->callApiUrl(str_replace('{id}', $masteryId, self::API_URL_STATIC_DATA_MASTERY_BY_ID), array_filter($queryParameters));
150
    }
151
152
    /**
153
     * @return ApiResult|null
154
     */
155 1
    public function getRealms()
156
    {
157 1
        return $this->callApiUrl(self::API_URL_STATIC_DATA_REALM, []);
158
    }
159
160
    /**
161
     * @param string $locale
162
     * @param string $version
163
     * @param array  $runeListData
164
     *
165
     * @return ApiResult|null
166
     */
167 1
    public function getRunes($locale = null, $version = null, array $runeListData = [])
168
    {
169 1
        $queryParameters = $this->handleQueryParametersForLocaleAndVersion($locale, $version, ['runeListData' => implode(',', $runeListData)]);
170
171 1
        return $this->callApiUrl(self::API_URL_STATIC_DATA_RUNES, array_filter($queryParameters));
172
    }
173
174
    /**
175
     * @param int    $runeId
176
     * @param string $locale
177
     * @param string $version
178
     * @param array  $runeData
179
     *
180
     * @return ApiResult|null
181
     */
182 1
    public function getRuneById($runeId, $locale = null, $version = null, array $runeData = [])
183
    {
184 1
        $queryParameters = $this->handleQueryParametersForLocaleAndVersion($locale, $version, ['runeData' => implode(',', $runeData)]);
185
186 1
        return $this->callApiUrl(str_replace('{id}', $runeId, self::API_URL_STATIC_DATA_RUNE_BY_ID), array_filter($queryParameters));
187
    }
188
189
    /**
190
     * @param string $locale
191
     * @param string $version
192
     * @param bool   $dataById
193
     * @param array  $spellData
194
     *
195
     * @return ApiResult|null
196
     */
197 1
    public function getSummonerSpells($locale = null, $version = null, $dataById = false, array $spellData = [])
198
    {
199 1
        $queryParameters = $this->handleQueryParametersForLocaleAndVersion($locale, $version, ['dataById' => (string) $dataById, 'spellData' => implode(',', $spellData)]);
200
201 1
        return $this->callApiUrl(self::API_URL_STATIC_DATA_SUMMONER_SPELLS, array_filter($queryParameters));
202
    }
203
204
    /**
205
     * @param int    $summonerSpellId
206
     * @param string $locale
207
     * @param string $version
208
     * @param array  $spellData
209
     *
210
     * @return ApiResult|null
211
     */
212 1
    public function getSummonerSpellById($summonerSpellId, $locale = null, $version = null, array $spellData = [])
213
    {
214 1
        $queryParameters = $this->handleQueryParametersForLocaleAndVersion($locale, $version, ['spellData' => implode(',', $spellData)]);
215
216 1
        return $this->callApiUrl(str_replace('{id}', $summonerSpellId, self::API_URL_STATIC_DATA_SUMMONER_SPELL_BY_ID), array_filter($queryParameters));
217
    }
218
219
    /**
220
     * @return ApiResult|null
221
     */
222 1
    public function getVersions()
223
    {
224 1
        return $this->callApiUrl(self::API_URL_STATIC_DATA_VERSIONS, []);
225
    }
226
227
    /**
228
     * @param string $locale
229
     * @param string $version
230
     * @param array  $otherParameters
231
     *
232
     * @return array
233
     */
234 13
    protected function handleQueryParametersForLocaleAndVersion($locale = null, $version = null, $otherParameters = [])
235
    {
236 13
        $queryParameters = [];
237
238 13
        if ($locale !== null) {
239 1
            $queryParameters['locale'] = (string) $locale;
240 1
        }
241 13
        if ($version !== null) {
242 1
            $queryParameters['version'] = (string) $version;
243 1
        }
244
245 13
        return array_merge($queryParameters, $otherParameters);
246
    }
247
}
248