Ejemplo n.º 1
0
 /**
  * @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;
 }