Total Complexity | 4 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | class GoogleClientService |
||
11 | { |
||
12 | /** |
||
13 | * @var Google_Client |
||
14 | */ |
||
15 | protected $client; |
||
16 | |||
17 | /** |
||
18 | * GoogleClientService constructor. |
||
19 | * @throws LogicException |
||
20 | * @throws Google_Exception |
||
21 | */ |
||
22 | public function __construct() |
||
23 | { |
||
24 | if (!getenv('SS_ANALYTICS_KEY')) { |
||
25 | throw new LogicException('No analytics API set up'); |
||
26 | } |
||
27 | |||
28 | $client = new Google_Client(); |
||
29 | $client->setAuthConfig(Director::baseFolder() . DIRECTORY_SEPARATOR . getenv('SS_ANALYTICS_KEY')); |
||
30 | $client->addScope(Google_Service_Analytics::ANALYTICS_READONLY); |
||
31 | |||
32 | $this->setClient($client); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @return Google_Client |
||
37 | */ |
||
38 | public function getClient() |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @param Google_Client $client |
||
45 | */ |
||
46 | public function setClient($client) |
||
49 | } |
||
50 | } |
||
51 |