src/OAuth2/Server.php
public function addStorage($storage, $key = null)
    {
        // if explicitly set to a valid key, do not "magically" set below
        if (isset($this->storageMap[$key])) {
            if (!is_null($storage) && !$storage instanceof $this->storageMap[$key]) {
                throw new \InvalidArgumentException(sprintf('storage of type "%s" must implement interface "%s"', $key, $this->storageMap[$key]));
            }
            $this->storages[$key] = $storage;

            // special logic to handle "client" and "client_credentials" strangeness
            if ($key === 'client' && !isset($this->storages['client_credentials'])) {
                if ($storage instanceof ClientCredentialsInterface) {
                    $this->storages['client_credentials'] = $storage;
                }
            } elseif ($key === 'client_credentials' && !isset($this->storages['client'])) {
                if ($storage instanceof ClientInterface) {
                    $this->storages['client'] = $storage;
                }
            }
        } elseif (!is_null($key) && !is_numeric($key)) {
            throw new \InvalidArgumentException(sprintf('unknown storage key "%s", must be one of [%s]', $key, implode(', ', array_keys($this->storageMap))));
        } else {
            $set = false;
            foreach ($this->storageMap as $type => $interface) {
                if ($storage instanceof $interface) {
                    $this->storages[$type] = $storage;
                    $set = true;
                }
            }

            if (!$set) {
                throw new \InvalidArgumentException(sprintf('storage of class "%s" must implement one of [%s]', get_class($storage), implode(', ', $this->storageMap)));
            }
        }
    }
public function addStorage($storage, $key = null)
    {
        // if explicitly set to a valid key, do not "magically" set below
        if (isset($this->storageMap[$key])) {
            if (!is_null($storage) && !$storage instanceof $this->storageMap[$key]) {
                throw new \InvalidArgumentException(sprintf('storage of type "%s" must implement interface "%s"', $key, $this->storageMap[$key]));
            }
            $this->storages[$key] = $storage;

            // special logic to handle "client" and "client_credentials" strangeness
            if ($key === 'client' && !isset($this->storages['client_credentials'])) {
                if ($storage instanceof ClientCredentialsInterface) {
                    $this->storages['client_credentials'] = $storage;
                }
            } elseif ($key === 'client_credentials' && !isset($this->storages['client'])) {
                if ($storage instanceof ClientInterface) {
                    $this->storages['client'] = $storage;
                }
            }
        } elseif (!is_null($key) && !is_numeric($key)) {
            throw new \InvalidArgumentException(sprintf('unknown storage key "%s", must be one of [%s]', $key, implode(', ', array_keys($this->storageMap))));
        } else {
            $set = false;
            foreach ($this->storageMap as $type => $interface) {
                if ($storage instanceof $interface) {
                    $this->storages[$type] = $storage;
                    $set = true;
                }
            }

            if (!$set) {
                throw new \InvalidArgumentException(sprintf('storage of class "%s" must implement one of [%s]', get_class($storage), implode(', ', $this->storageMap)));
            }
        }
    }
public function addStorage ( $ storage , $ key = null ) { // if explicitly set to a valid key, do not "magically" set below if ( isset ( $ this -> storageMap [ $ key ] ) ) { if ( ! is_null ( $ storage ) && ! $ storage instanceof $ this -> storageMap [ $ key ] ) { throw new \ InvalidArgumentException ( sprintf ( 'storage of type "%s" must implement interface "%s"' , $ key , $ this -> storageMap [ $ key ] ) ) ; } $ this -> storages [ $ key ] = $ storage ; // special logic to handle "client" and "client_credentials" strangeness if ( $ key === 'client' && ! isset ( $ this -> storages [ 'client_credentials' ] ) ) { if ( $ storage instanceof ClientCredentialsInterface ) { $ this -> storages [ 'client_credentials' ] = $ storage ; } } elseif ( $ key === 'client_credentials' && ! isset ( $ this -> storages [ 'client' ] ) ) { if ( $ storage instanceof ClientInterface ) { $ this -> storages [ 'client' ] = $ storage ; } } } elseif ( ! is_null ( $ key ) && ! is_numeric ( $ key ) ) { throw new \ InvalidArgumentException ( sprintf ( 'unknown storage key "%s", must be one of [%s]' , $ key , implode ( ', ' , array_keys ( $ this -> storageMap ) ) ) ) ; } else { $ set = false ; foreach ( $ this -> storageMap as $ type => $ interface ) { if ( $ storage instanceof $ interface ) { $ this -> storages [ $ type ] = $ storage ; $ set = true ; } } if ( ! $ set ) { throw new \ InvalidArgumentException ( sprintf ( 'storage of class "%s" must implement one of [%s]' , get_class ( $ storage ) , implode ( ', ' , $ this -> storageMap ) ) ) ; } } }
Set a storage object for the server

@param object $storage - An object implementing one of the Storage interfaces
@param mixed $key - If null, the storage is set to the key of each storage interface it implements

@throws InvalidArgumentException
@see storageMap
Set a storage object for the server