null, 'projectId' => null, 'projectIdRequired' => \false, 'hasEmulator' => \false, 'credentials' => null]; if ($config['projectId']) { return $config['projectId']; } if ($config['hasEmulator']) { return 'emulator-project'; } if ($config['credentials'] && $config['credentials'] instanceof ProjectIdProviderInterface && ($projectId = $config['credentials']->getProjectId())) { return $projectId; } if (\getenv('GOOGLE_CLOUD_PROJECT')) { return \getenv('GOOGLE_CLOUD_PROJECT'); } if (\getenv('GCLOUD_PROJECT')) { return \getenv('GCLOUD_PROJECT'); } $this->throwExceptionIfProjectIdRequired($config); return ''; } /** * Throws an exception if project id is required. * @param array $config * @throws GoogleException */ private function throwExceptionIfProjectIdRequired(array $config) { if ($config['projectIdRequired']) { throw new GoogleException('No project ID was provided, ' . 'and we were unable to detect a default project ID.'); } } }