Core/src/RequestWrapperTrait.php
public function setCommonDefaults(array $config)
    {
        $config += [
            'authCache' => new MemoryCacheItemPool(),
            'authCacheOptions' => [],
            'credentialsFetcher' => null,
            'keyFile' => null,
            'requestTimeout' => null,
            'retries' => 3,
            'scopes' => null
        ];

        if ($config['credentialsFetcher'] && !$config['credentialsFetcher'] instanceof FetchAuthTokenInterface) {
            throw new \InvalidArgumentException('credentialsFetcher must implement FetchAuthTokenInterface.');
        }

        if (!$config['authCache'] instanceof CacheItemPoolInterface) {
            throw new \InvalidArgumentException('authCache must implement CacheItemPoolInterface.');
        }

        $this->authCache = $config['authCache'];
        $this->authCacheOptions = $config['authCacheOptions'];
        $this->credentialsFetcher = $config['credentialsFetcher'];
        $this->retries = $config['retries'];
        $this->scopes = $config['scopes'];
        $this->keyFile = $config['keyFile'];
        $this->requestTimeout = $config['requestTimeout'];
    }
public function setCommonDefaults(array $config)
    {
        $config += [
            'authCache' => new MemoryCacheItemPool(),
            'authCacheOptions' => [],
            'credentialsFetcher' => null,
            'keyFile' => null,
            'requestTimeout' => null,
            'retries' => 3,
            'scopes' => null
        ];

        if ($config['credentialsFetcher'] && !$config['credentialsFetcher'] instanceof FetchAuthTokenInterface) {
            throw new \InvalidArgumentException('credentialsFetcher must implement FetchAuthTokenInterface.');
        }

        if (!$config['authCache'] instanceof CacheItemPoolInterface) {
            throw new \InvalidArgumentException('authCache must implement CacheItemPoolInterface.');
        }

        $this->authCache = $config['authCache'];
        $this->authCacheOptions = $config['authCacheOptions'];
        $this->credentialsFetcher = $config['credentialsFetcher'];
        $this->retries = $config['retries'];
        $this->scopes = $config['scopes'];
        $this->keyFile = $config['keyFile'];
        $this->requestTimeout = $config['requestTimeout'];
    }
public function setCommonDefaults ( array $ config ) { $ config += [ 'authCache' => new MemoryCacheItemPool ( ) , 'authCacheOptions' => [ ] , 'credentialsFetcher' => null , 'keyFile' => null , 'requestTimeout' => null , 'retries' => 3 , 'scopes' => null ] ; if ( $ config [ 'credentialsFetcher' ] && ! $ config [ 'credentialsFetcher' ] instanceof FetchAuthTokenInterface ) { throw new \ InvalidArgumentException ( 'credentialsFetcher must implement FetchAuthTokenInterface.' ) ; } if ( ! $ config [ 'authCache' ] instanceof CacheItemPoolInterface ) { throw new \ InvalidArgumentException ( 'authCache must implement CacheItemPoolInterface.' ) ; } $ this -> authCache = $ config [ 'authCache' ] ; $ this -> authCacheOptions = $ config [ 'authCacheOptions' ] ; $ this -> credentialsFetcher = $ config [ 'credentialsFetcher' ] ; $ this -> retries = $ config [ 'retries' ] ; $ this -> scopes = $ config [ 'scopes' ] ; $ this -> keyFile = $ config [ 'keyFile' ] ; $ this -> requestTimeout = $ config [ 'requestTimeout' ] ; }
Sets common defaults between request wrappers.

@param array $config {
Configuration options.

@type CacheItemPoolInterface $authCache A cache for storing access
tokens. **Defaults to** a simple in memory implementation.
@type array $authCacheOptions Cache configuration options.
@type FetchAuthTokenInterface $credentialsFetcher A credentials
fetcher instance.
@type array $keyFile The contents of the service account credentials
.json file retrieved from the Google Developer's Console.
Ex: `json_decode(file_get_contents($path), true)`.
@type float $requestTimeout Seconds to wait before timing out the
request. **Defaults to** `0` with REST and `60` with gRPC.
@type int $retries Number of retries for a failed request.
**Defaults to** `3`.
@type array $scopes Scopes to be used for the request.
}
@throws \InvalidArgumentException
Sets common defaults between request wrappers .