GoogleClientService::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 11
rs 9.4285
1
<?php
2
3
class GoogleClientService
4
{
5
    /**
6
     * @var Google_Client
7
     */
8
    protected $client;
9
10
    /**
11
     * GoogleClientService constructor.
12
     * @throws LogicException
13
     * @throws \Google_Exception
14
     */
15
    public function __construct()
16
    {
17
        if (!defined('SS_ANALYTICS_KEY') || !file_exists(SS_ANALYTICS_KEY)) {
18
            throw new LogicException('No analytics API set up');
19
        }
20
21
        $client = new Google_Client();
22
        $client->setAuthConfig(SS_ANALYTICS_KEY);
23
        $client->addScope(Google_Service_Analytics::ANALYTICS_READONLY);
24
25
        $this->setClient($client);
26
    }
27
28
    /**
29
     * @return Google_Client
30
     */
31
    public function getClient()
32
    {
33
        return $this->client;
34
    }
35
36
    /**
37
     * @param Google_Client $client
38
     */
39
    public function setClient($client)
40
    {
41
        $this->client = $client;
42
    }
43
}
44