session = $session; } /** * Returns the current token or throws an exception if none is found. * * @throws \Exception */ public function getToken(): string { $token = $this->session->get('requesttoken'); if (empty($token)) { throw new \Exception('Session does not contain a requesttoken'); } return $token; } /** * Set the valid current token to $value. */ public function setToken(string $value): void { $this->session->set('requesttoken', $value); } /** * Removes the current token. */ public function removeToken(): void { $this->session->remove('requesttoken'); } /** * Whether the storage has a storage. */ public function hasToken(): bool { return $this->session->exists('requesttoken'); } }