| 1 | <?php |
||
| 9 | class SimpleCacheTokenPersistence implements TokenPersistenceInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var CacheInterface |
||
| 13 | */ |
||
| 14 | private $cache; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var string |
||
| 18 | */ |
||
| 19 | private $cacheKey; |
||
| 20 | |||
| 21 | 12 | public function __construct(CacheInterface $cache, $cacheKey = 'guzzle-oauth2-token') |
|
| 26 | |||
| 27 | 12 | public function saveToken(TokenInterface $token) |
|
| 31 | |||
| 32 | 12 | public function restoreToken(TokenInterface $token) |
|
| 33 | { |
||
| 34 | 12 | $data = $this->cache->get($this->cacheKey); |
|
| 35 | |||
| 36 | 12 | if (!is_array($data)) { |
|
| 37 | 10 | return null; |
|
| 38 | } |
||
| 39 | |||
| 40 | 2 | return $token->unserialize($data); |
|
| 41 | } |
||
| 42 | |||
| 43 | 12 | public function deleteToken() |
|
| 47 | } |
||
| 48 |