Core/src/ClientTrait.php
private function getKeyFile(array $config = [])
    {
        $config += [
            'keyFile' => null,
            'keyFilePath' => null,
        ];

        if ($config['keyFile']) {
            return $config['keyFile'];
        }

        if ($config['keyFilePath']) {
            if (!file_exists($config['keyFilePath'])) {
                throw new GoogleException(sprintf(
                    'Given keyfile path %s does not exist',
                    $config['keyFilePath']
                ));
            }

            try {
                $keyFileData = $this->jsonDecode(file_get_contents($config['keyFilePath']), true);
            } catch (\InvalidArgumentException $ex) {
                throw new GoogleException(sprintf(
                    'Given keyfile at path %s was invalid',
                    $config['keyFilePath']
                ));
            }

            return $keyFileData;
        }

        return CredentialsLoader::fromEnv()
            ?: CredentialsLoader::fromWellKnownFile();
    }
private function getKeyFile(array $config = [])
    {
        $config += [
            'keyFile' => null,
            'keyFilePath' => null,
        ];

        if ($config['keyFile']) {
            return $config['keyFile'];
        }

        if ($config['keyFilePath']) {
            if (!file_exists($config['keyFilePath'])) {
                throw new GoogleException(sprintf(
                    'Given keyfile path %s does not exist',
                    $config['keyFilePath']
                ));
            }

            try {
                $keyFileData = $this->jsonDecode(file_get_contents($config['keyFilePath']), true);
            } catch (\InvalidArgumentException $ex) {
                throw new GoogleException(sprintf(
                    'Given keyfile at path %s was invalid',
                    $config['keyFilePath']
                ));
            }

            return $keyFileData;
        }

        return CredentialsLoader::fromEnv()
            ?: CredentialsLoader::fromWellKnownFile();
    }
private function getKeyFile ( array $ config = [ ] ) { $ config += [ 'keyFile' => null , 'keyFilePath' => null , ] ; if ( $ config [ 'keyFile' ] ) { return $ config [ 'keyFile' ] ; } if ( $ config [ 'keyFilePath' ] ) { if ( ! file_exists ( $ config [ 'keyFilePath' ] ) ) { throw new GoogleException ( sprintf ( 'Given keyfile path %s does not exist' , $ config [ 'keyFilePath' ] ) ) ; } try { $ keyFileData = $ this -> jsonDecode ( file_get_contents ( $ config [ 'keyFilePath' ] ) , true ) ; } catch ( \ InvalidArgumentException $ ex ) { throw new GoogleException ( sprintf ( 'Given keyfile at path %s was invalid' , $ config [ 'keyFilePath' ] ) ) ; } return $ keyFileData ; } return CredentialsLoader :: fromEnv ( ) ? : CredentialsLoader :: fromWellKnownFile ( ) ; }
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.

@param  array $config
@return array|null Key data
@throws GoogleException
Get a keyfile if it exists .