1 | <?php |
||
12 | class API |
||
13 | { |
||
14 | /** |
||
15 | * @var \Burthorpe\Runescape\RS3\Skills\Repository |
||
16 | */ |
||
17 | protected $skills; |
||
18 | |||
19 | /** |
||
20 | * Guzzle HTTP client for making requests |
||
21 | * |
||
22 | * @var \GuzzleHttp\Client |
||
23 | */ |
||
24 | protected $guzzle; |
||
25 | |||
26 | /** |
||
27 | * Array of resource URLs |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $endpoints = [ |
||
32 | 'hiscores' => 'http://hiscore.runescape.com/index_lite.ws?player=%s', |
||
33 | ]; |
||
34 | |||
35 | /** |
||
36 | * Class constructor |
||
37 | */ |
||
38 | 11 | public function __construct() |
|
48 | |||
49 | /** |
||
50 | * Get a players statistics from the hiscores API feed |
||
51 | * |
||
52 | * @return \Burthorpe\Runescape\RS3\Stats\Repository|bool |
||
53 | * |
||
54 | * @throws \Burthorpe\Exception\UnknownPlayerException |
||
55 | */ |
||
56 | 5 | public function stats($rsn) |
|
57 | { |
||
58 | 5 | $request = new Request('GET', sprintf($this->endpoints['hiscores'], $rsn)); |
|
59 | |||
60 | try { |
||
61 | 5 | $response = $this->guzzle->send($request); |
|
62 | 5 | } catch (RequestException $e) { |
|
63 | 1 | throw new UnknownPlayerException($rsn); |
|
64 | } |
||
65 | |||
66 | 4 | return StatsRepository::factory($response->getBody()); |
|
67 | } |
||
68 | |||
69 | /** |
||
70 | * Get access to the skills helper |
||
71 | * |
||
72 | * @return \Burthorpe\Runescape\RS3\Skills\Repository |
||
73 | */ |
||
74 | 1 | public function getSkills() |
|
78 | |||
79 | /** |
||
80 | * Calculates a players combat level |
||
81 | * |
||
82 | * @param int $attack |
||
83 | * @param int $strength |
||
84 | * @param int $magic |
||
85 | * @param int $ranged |
||
86 | * @param int $defence |
||
87 | * @param int $constitution |
||
88 | * @param int $prayer |
||
89 | * @param int $summoning |
||
90 | * @param bool $float |
||
91 | * @return int |
||
92 | */ |
||
93 | 2 | public function calculateCombatLevel($attack, $strength, $magic, $ranged, $defence, $constitution, $prayer, $summoning, $float = false) |
|
101 | } |
||
102 |