client = $client; } /** * Get the credentials from the cache in the validity period. * * @return array|null */ public function getCredentialsInCache() { if (isset(self::$credentialsCache[$this->key()])) { $result = self::$credentialsCache[$this->key()]; if (\strtotime($result['Expiration']) - \time() >= $this->expirationSlot) { return $result; } unset(self::$credentialsCache[$this->key()]); } return null; } /** * Get the toString of the credentials as the key. * * @return string */ protected function key() { return (string)$this->client->getCredential(); } /** * Cache credentials. * * @param array $credential */ protected function cache(array $credential) { self::$credentialsCache[$this->key()] = $credential; } }