@@ -141,14 +141,18 @@ public function __construct()
141141 /**
142142 * Sets API key
143143 *
144- * @param string $apiKeyIdentifier API key identifier (authentication scheme)
145- * @param string $key API key or token
144+ * @param string $apiKeyIdentifier API key identifier (authentication scheme)
145+ * @param string|null $key API key or token
146146 *
147147 * @return $this
148148 */
149- public function setApiKey (string $ apiKeyIdentifier , string $ key ): static
149+ public function setApiKey (string $ apiKeyIdentifier , ? string $ key ): static
150150 {
151- $ this ->apiKeys [$ apiKeyIdentifier ] = $ key ;
151+ if ($ key === null ) {
152+ unset($ this ->apiKeys [$ apiKeyIdentifier ]);
153+ } else {
154+ $ this ->apiKeys [$ apiKeyIdentifier ] = $ key ;
155+ }
152156 return $ this ;
153157 }
154158
@@ -167,14 +171,18 @@ public function getApiKey(string $apiKeyIdentifier): ?string
167171 /**
168172 * Sets the prefix for API key (e.g. Bearer)
169173 *
170- * @param string $apiKeyIdentifier API key identifier (authentication scheme)
171- * @param string $prefix API key prefix, e.g. Bearer
174+ * @param string $apiKeyIdentifier API key identifier (authentication scheme)
175+ * @param string|null $prefix API key prefix, e.g. Bearer
172176 *
173177 * @return $this
174178 */
175- public function setApiKeyPrefix (string $ apiKeyIdentifier , string $ prefix ): static
179+ public function setApiKeyPrefix (string $ apiKeyIdentifier , ? string $ prefix ): static
176180 {
177- $ this ->apiKeyPrefixes [$ apiKeyIdentifier ] = $ prefix ;
181+ if ($ prefix === null ) {
182+ unset($ this ->apiKeyPrefixes [$ apiKeyIdentifier ]);
183+ } else {
184+ $ this ->apiKeyPrefixes [$ apiKeyIdentifier ] = $ prefix ;
185+ }
178186 return $ this ;
179187 }
180188
0 commit comments