1 | <?php |
||
16 | class ClientWithCache |
||
17 | { |
||
18 | private const CACHE_DIR = '/tmp/battlerite'; |
||
19 | |||
20 | private const CACHE_PREFIX = 'battlerite-'; |
||
21 | |||
22 | /** |
||
23 | * @var Client |
||
24 | */ |
||
25 | private $client; |
||
26 | |||
27 | /** |
||
28 | * @var Cache |
||
29 | */ |
||
30 | private $cache; |
||
31 | |||
32 | /** |
||
33 | * @var int |
||
34 | */ |
||
35 | private $cacheLifetime = 300; |
||
36 | |||
37 | 7 | public function __construct(Client $client, Cache $cache, int $cacheLifetime) |
|
43 | |||
44 | /** |
||
45 | * Create default API client setup with a filesystem caching layer |
||
46 | */ |
||
47 | 1 | public static function create(string $apiKey): self |
|
60 | |||
61 | /** |
||
62 | * Create default API client setup with a custom caching layer |
||
63 | */ |
||
64 | 1 | public static function createWithCache(string $apiKey, Cache $cache, int $cacheLifetime): self |
|
77 | |||
78 | 1 | public function getPlayer(string $playerId): DetailedPlayer |
|
88 | |||
89 | 1 | public function getMatch(string $matchId): DetailedMatch |
|
99 | |||
100 | 1 | public function getStatus(): Status |
|
104 | |||
105 | 1 | public function getMatches(MatchesQuery $query = null): Matches |
|
109 | |||
110 | 1 | public function getPlayers(PlayersQuery $query = null): Players |
|
114 | } |
||
115 |