/**
  * @param string|null $acceptHeader The header 'Accept' data
  *
  * @return string
  *
  * @throws UnauthorizedAccessException
  * @throws TimeoutException
  */
 public function getVersion($acceptHeader = null)
 {
     // Retrieve and cache the version
     $cacheName = 'replay.version';
     if ($this->cache->has($cacheName)) {
         // Cache the version to avoid a next call
         $version = $this->cache->get($cacheName);
     } else {
         $version = $this->apiClient->getObserverVersion();
         if (false === $version) {
             throw new TimeoutException('The server has timed out.');
         }
         $this->cache->set($cacheName, $version, 86400);
         // 1 day
     }
     if (!$this->isAuthorized($acceptHeader)) {
         throw new UnauthorizedAccessException();
     }
     return $version;
 }
 /**
  * @param ReplayInterface $replay
  */
 public function updateMetas(ReplayInterface $replay)
 {
     // Download end game metas
     $endMetas = $this->client->getMetas($replay->getRegion(), $replay->getGameId());
     $endMetas = json_decode($endMetas, true);
     // Update metas
     $metas = $replay->getMetas();
     $metas['lastChunkId'] = $replay->getLastChunkId();
     $metas['endGameChunkId'] = $replay->getLastChunkId();
     $metas['lastKeyFrameId'] = $replay->getLastKeyframeId();
     $metas['endGameKeyFrameId'] = $replay->getLastKeyframeId();
     $metas['firstChunkId'] = $this->findFirstChunkId($metas);
     $metas['gameEnded'] = true;
     $metas['gameLength'] = $endMetas['gameLength'];
     // Update replay object
     $replay->setDuration(round($endMetas['gameLength'] / 1000));
     $replay->setMetas($metas);
     // Save metas
     $this->saveMetas($replay);
 }
 /**
  * @return array
  */
 protected function getDefaultConfigs()
 {
     return ['auth.strict' => false, 'api.client' => ReplayClient::getDefaultConfigs()];
 }