Completed
Pull Request — master (#121)
by
unknown
02:02
created

AnalyticsClientFactory::createAuthenticatedGoogleClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 1
1
<?php
2
3
namespace Spatie\Analytics;
4
5
use Google_Client;
6
use Google_Service_Analytics;
7
use Illuminate\Contracts\Cache\Repository;
8
9
class AnalyticsClientFactory
10
{
11
    public static function createForConfig(Google_Client $client, array $analyticsConfig): AnalyticsClient
12
    {
13
        $googleService = new Google_Service_Analytics($client);
14
15
        return self::createAnalyticsClient($analyticsConfig, $googleService);
16
    }
17
18
    protected static function createAnalyticsClient(array $analyticsConfig, Google_Service_Analytics $googleService): AnalyticsClient
19
    {
20
        $client = new AnalyticsClient($googleService, app(Repository::class));
21
22
        $client->setCacheLifeTimeInMinutes($analyticsConfig['cache_lifetime_in_minutes']);
23
24
        return $client;
25
    }
26
}
27