Client   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 35
ccs 10
cts 11
cp 0.9091
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 11 1
A checkAuthConfigFile() 0 6 2
1
<?php
2
3
namespace Nikaia\TranslationSheet\Client;
4
5
class Client extends \Google_Client
6
{
7
    /**
8
     * Return configured google api client.
9
     *
10
     * @param $authConfigFile
11
     * @param $applicationName
12
     *
13
     * @return Client
14
     */
15 20
    public static function create($authConfigFile, $applicationName)
16
    {
17 20
        self::checkAuthConfigFile($authConfigFile);
18
19 20
        $client = new static();
20 20
        $client->setAuthConfig($authConfigFile);
21 20
        $client->setApplicationName($applicationName);
22 20
        $client->setScopes(\Google_Service_Sheets::SPREADSHEETS);
23
24 20
        return $client;
25
    }
26
27
    /**
28
     * Throw an exception if google service config file is not found.
29
     *
30
     * @param $authConfigFile
31
     * @throws \Exception
32
     */
33 20
    private static function checkAuthConfigFile($authConfigFile)
34
    {
35 20
        if (! file_exists($authConfigFile)) {
36
            throw new \Exception('You must specify a valid google service authentication file. Given file ['.$authConfigFile.'] does not exists');
37
        }
38 20
    }
39
}
40