[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/vendor/lusitanian/oauth/src/OAuth/Common/Storage/ -> Memory.php (source)

   1  <?php
   2  
   3  namespace OAuth\Common\Storage;
   4  
   5  use OAuth\Common\Token\TokenInterface;
   6  use OAuth\Common\Storage\Exception\TokenNotFoundException;
   7  
   8  /*
   9   * Stores a token in-memory only (destroyed at end of script execution).
  10   */
  11  class Memory implements TokenStorageInterface
  12  {
  13      /**
  14       * @var object|TokenInterface
  15       */
  16      protected $tokens;
  17  
  18      public function __construct()
  19      {
  20          $this->tokens = array();
  21      }
  22  
  23      /**
  24       * {@inheritDoc}
  25       */
  26      public function retrieveAccessToken($service)
  27      {
  28          if ($this->hasAccessToken($service)) {
  29              return $this->tokens[$service];
  30          }
  31  
  32          throw new TokenNotFoundException('Token not stored');
  33      }
  34  
  35      /**
  36       * {@inheritDoc}
  37       */
  38      public function storeAccessToken($service, TokenInterface $token)
  39      {
  40          $this->tokens[$service] = $token;
  41  
  42          // allow chaining
  43          return $this;
  44      }
  45  
  46      /**
  47       * {@inheritDoc}
  48       */
  49      public function hasAccessToken($service)
  50      {
  51          return isset($this->tokens[$service]) && $this->tokens[$service] instanceof TokenInterface;
  52      }
  53  
  54      /**
  55       * {@inheritDoc}
  56       */
  57      public function clearToken($service)
  58      {
  59          if (array_key_exists($service, $this->tokens)) {
  60              unset($this->tokens[$service]);
  61          }
  62  
  63          // allow chaining
  64          return $this;
  65      }
  66  
  67      /**
  68       * {@inheritDoc}
  69       */
  70      public function clearAllTokens()
  71      {
  72          $this->tokens = array();
  73  
  74          // allow chaining
  75          return $this;
  76      }
  77  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1