Provides functionality common to each service client.

Trait
Methods
protected getMetaData()
 

Abstract the Metadata instantiation for unit testing

  • codeCoverageIgnore
  • return Metadata
protected isGrpcLoaded()
 

Abstract the checking of the grpc extension for unit testing.

  • codeCoverageIgnore
  • return bool
protected onGce( $httpHandler)
 

Abstract the GCECredentials call so we can mock it in the unit tests!

  • codeCoverageIgnore
  • return bool
Properties
private $projectId
 
  • var string|null The project ID created in the Google Developers Console.
Methods
private configureAuthentication(array $config)
 

Fetch and validate the keyfile and set the project ID.

  • return array
private detectProjectId(array $config)
 

Detect and return a project ID.

Process:

  1. If $config['projectId'] is set, use that.
  2. If an emulator is enabled, return a dummy value.
  3. If $config['keyFile'] is set, attempt to retrieve a project ID from
    that.
  4. Check GOOGLE_CLOUD_PROJECT environment variable.
  5. Check GCLOUD_PROJECT environment variable.
  6. If code is running on compute engine, try to get the project ID from
    the metadata store.
  7. Throw exception.
  • return string
  • throws GoogleException
private getConnectionType(array $config)
 

Get either a gRPC or REST connection based on the provided config
and the system dependencies available.

  • return string
  • throws GoogleException
private getGrpcInstallationMessage()
 
  • return string
private getKeyFile(array $config = [])
 

Get a keyfile if it exists.

Process:

  1. If $config['keyFile'] is set, use that.
  2. If $config['keyFilePath'] is set, load the file and use that.
  3. If GOOGLE_APPLICATION_CREDENTIALS environment variable is set, load
    from that location and use that.
  4. If OS-specific well-known-file is set, load from that location and use
    that.
  • return array|null Key data
  • throws GoogleException
private static jsonDecode( $json, $assoc = false, $depth = 512, $options = 0)
 
  • return mixed
  • throws InvalidArgumentException
private static jsonEncode( $value, $options = 0, $depth = 512)
 
  • return string
  • throws InvalidArgumentException
private requireGrpc()
 

Throw an exception if the gRPC extension is not loaded.

  • throws GoogleException
Methods
private static jsonDecode( $json, $assoc = false, $depth = 512, $options = 0)
 
  • return mixed
  • throws InvalidArgumentException
private static jsonEncode( $value, $options = 0, $depth = 512)
 
  • return string
  • throws InvalidArgumentException
© 2020 Bruce Wells
Search Namespaces \ Classes
ConfigurationNumbers (0-9.) only