1 | <?php |
||
11 | class ClientWithCache |
||
12 | { |
||
13 | private const CACHE_DIR = '/tmp/battlerite'; |
||
14 | |||
15 | private const CACHE_PREFIX = 'battlerite-'; |
||
16 | |||
17 | /** |
||
18 | * @var Client |
||
19 | */ |
||
20 | private $client; |
||
21 | |||
22 | /** |
||
23 | * @var Cache |
||
24 | */ |
||
25 | private $cache; |
||
26 | |||
27 | /** |
||
28 | * @var int |
||
29 | */ |
||
30 | private $cacheLifetime = 300; |
||
31 | |||
32 | 4 | public function __construct(Client $client, Cache $cache, int $cacheLifetime) |
|
38 | |||
39 | /** |
||
40 | * Create default API client setup with a filesystem caching layer |
||
41 | */ |
||
42 | 1 | public static function create(string $apiKey): self |
|
55 | |||
56 | /** |
||
57 | * Create default API client setup with a custom caching layer |
||
58 | */ |
||
59 | 1 | public static function createWithCache(string $apiKey, Cache $cache, int $cacheLifetime): self |
|
72 | |||
73 | 1 | public function getPlayer(string $playerId): DetailedPlayer |
|
83 | |||
84 | 1 | public function getMatch(string $matchId): DetailedMatch |
|
94 | } |
||
95 |