����JFIF��x�x����'
| Server IP : 78.140.185.180 / Your IP : 216.73.216.169 Web Server : LiteSpeed System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : builderbox ( 1072) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/builderbox/./././public_html/vendor/spatie/laravel-analytics/src/ |
Upload File : |
<?php
namespace Spatie\Analytics;
use Google_Client;
use Google_Service_Analytics;
use Illuminate\Contracts\Cache\Repository;
use Illuminate\Support\Facades\Cache;
use Symfony\Component\Cache\Adapter\Psr16Adapter;
class AnalyticsClientFactory
{
public static function createForConfig(array $analyticsConfig): AnalyticsClient
{
$authenticatedClient = self::createAuthenticatedGoogleClient($analyticsConfig);
$googleService = new Google_Service_Analytics($authenticatedClient);
return self::createAnalyticsClient($analyticsConfig, $googleService);
}
public static function createAuthenticatedGoogleClient(array $config): Google_Client
{
$client = new Google_Client();
$client->setScopes([
Google_Service_Analytics::ANALYTICS_READONLY,
]);
$client->setAuthConfig($config['service_account_credentials_json']);
self::configureCache($client, $config['cache']);
return $client;
}
protected static function configureCache(Google_Client $client, $config)
{
$config = collect($config);
$store = Cache::store($config->get('store'));
$cache = new Psr16Adapter($store);
$client->setCache($cache);
$client->setCacheConfig(
$config->except('store')->toArray()
);
}
protected static function createAnalyticsClient(array $analyticsConfig, Google_Service_Analytics $googleService): AnalyticsClient
{
$client = new AnalyticsClient($googleService, app(Repository::class));
$client->setCacheLifeTimeInMinutes($analyticsConfig['cache_lifetime_in_minutes']);
return $client;
}
}