Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Memory.php

Zuletzt modifiziert: 02.04.2025, 15:04 - Dateigröße: 2.71 KiB


001  <?php
002   
003  namespace OAuth\Common\Storage;
004   
005  use OAuth\Common\Storage\Exception\AuthorizationStateNotFoundException;
006  use OAuth\Common\Storage\Exception\TokenNotFoundException;
007  use OAuth\Common\Token\TokenInterface;
008   
009  // Stores a token in-memory only (destroyed at end of script execution).
010  class Memory implements TokenStorageInterface
011  {
012      /**
013       * @var object|TokenInterface
014       */
015      protected $tokens;
016   
017      /**
018       * @var array
019       */
020      protected $states;
021   
022      public function __construct()
023      {
024          $this->tokens = [];
025          $this->states = [];
026      }
027   
028      /**
029       * {@inheritdoc}
030       */
031      public function retrieveAccessToken($service)
032      {
033          if ($this->hasAccessToken($service)) {
034              return $this->tokens[$service];
035          }
036   
037          throw new TokenNotFoundException('Token not stored');
038      }
039   
040      /**
041       * {@inheritdoc}
042       */
043      public function storeAccessToken($service, TokenInterface $token)
044      {
045          $this->tokens[$service] = $token;
046   
047          // allow chaining
048          return $this;
049      }
050   
051      /**
052       * {@inheritdoc}
053       */
054      public function hasAccessToken($service)
055      {
056          return isset($this->tokens[$service]) && $this->tokens[$service] instanceof TokenInterface;
057      }
058   
059      /**
060       * {@inheritdoc}
061       */
062      public function clearToken($service)
063      {
064          if (array_key_exists($service, $this->tokens)) {
065              unset($this->tokens[$service]);
066          }
067   
068          // allow chaining
069          return $this;
070      }
071   
072      /**
073       * {@inheritdoc}
074       */
075      public function clearAllTokens()
076      {
077          $this->tokens = [];
078   
079          // allow chaining
080          return $this;
081      }
082   
083      /**
084       * {@inheritdoc}
085       */
086      public function retrieveAuthorizationState($service)
087      {
088          if ($this->hasAuthorizationState($service)) {
089              return $this->states[$service];
090          }
091   
092          throw new AuthorizationStateNotFoundException('State not stored');
093      }
094   
095      /**
096       * {@inheritdoc}
097       */
098      public function storeAuthorizationState($service, $state)
099      {
100          $this->states[$service] = $state;
101   
102          // allow chaining
103          return $this;
104      }
105   
106      /**
107       * {@inheritdoc}
108       */
109      public function hasAuthorizationState($service)
110      {
111          return isset($this->states[$service]) && null !== $this->states[$service];
112      }
113   
114      /**
115       * {@inheritdoc}
116       */
117      public function clearAuthorizationState($service)
118      {
119          if (array_key_exists($service, $this->states)) {
120              unset($this->states[$service]);
121          }
122   
123          // allow chaining
124          return $this;
125      }
126   
127      /**
128       * {@inheritdoc}
129       */
130      public function clearAllAuthorizationStates()
131      {
132          $this->states = [];
133   
134          // allow chaining
135          return $this;
136      }
137  }
138