url = $url; } public function setApiKey(string $apiKey): self { $this->apiKey = $apiKey; } public function call(string $api, string $method, array $arguments = []): mixed { $cacheKey = sprintf('%s_%s_%s', $api, $method, sha1(serialize($arguments))); return $this->cache->get($cacheKey, function (ItemInterface $item): string { $item->expiresAfter(3600); $item->tag([$api, $method]); $apiClient = $this->getClient()->getApi($api); $value = call_user_method_array($method, $apiClient, $arguments); return $value; }); } public function getClient(): ?Psr18Client { if (!$this->client) { $guzzle = new GuzzleClient(); $factory = new GuzzleHttpFactory(); $this->client = new Psr18Client( $guzzle, $factory, $factory, $this->url, $this->apiKey ); } return $this->client; } }