/**
  * Obtains the default FetchAuthTokenInterface implementation to use
  * in this environment.
  *
  * If supplied, $scope is used to in creating the credentials instance if
  * this does not fallback to the Compute Engine defaults.
  *
  * @param string|array scope the scope of the access request, expressed
  *   either as an Array or as a space-delimited String.
  * @param callable $httpHandler callback which delivers psr7 request
  * @param array $cacheConfig configuration for the cache when it's present
  * @param CacheItemPoolInterface $cache
  *
  * @return CredentialsLoader
  *
  * @throws DomainException if no implementation can be obtained.
  */
 public static function getCredentials($scope = null, callable $httpHandler = null, array $cacheConfig = null, CacheItemPoolInterface $cache = null)
 {
     $creds = null;
     $jsonKey = CredentialsLoader::fromEnv() ?: CredentialsLoader::fromWellKnownFile();
     if (!is_null($jsonKey)) {
         $creds = CredentialsLoader::makeCredentials($scope, $jsonKey);
     }
     if (AppIdentityCredentials::onAppEngine() && !GCECredentials::onAppEngineFlexible()) {
         $creds = new AppIdentityCredentials($scope);
     }
     if (GCECredentials::onGce($httpHandler)) {
         $creds = new GCECredentials();
     }
     if (is_null($creds)) {
         throw new \DomainException(self::notFound());
     }
     if (!is_null($cache)) {
         $creds = new FetchAuthTokenCache($creds, $cacheConfig, $cache);
     }
     return $creds;
 }
 public function testIsTrueWhenGaeVmIsTrue()
 {
     $_SERVER['GAE_VM'] = 'true';
     $this->assertTrue(GCECredentials::onAppEngineFlexible());
 }