| Total Complexity | 5 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 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) |
||
| 42 | } |
||
| 43 | } |
||
| 44 |