StatClientFactory::createForConfig()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace SchulzeFelix\Stat;
4
5
use GuzzleHttp\Client;
6
7
class StatClientFactory
8
{
9
    public static function createForConfig(array $statConfig): StatClient
10
    {
11
        $guzzleClient = new Client(
12
            [
13
                'headers' => [
14
                    'User-Agent' => 'Laravel Stat Search Analytics Client',
15
                    'Accept-Encoding' => 'gzip, deflate, sdch',
16
                ],
17
                'base_uri' => self::buildBaseUri($statConfig),
18
                'timeout'  => 60.0,
19
            ]
20
        );
21
22
        $client = new StatClient($guzzleClient);
23
24
        return $client;
25
    }
26
27
    protected static function buildBaseUri(array $statConfig)
28
    {
29
        $baseUri = sprintf('https://%s/api/v2/%s/', $statConfig['subdomain'], $statConfig['key']);
30
31
        return $baseUri;
32
    }
33
}
34