GoogleClientService   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 39
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setClient() 0 3 1
A getClient() 0 3 1
A __construct() 0 11 3
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