StatClientFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createForConfig() 0 17 1
A buildBaseUri() 0 6 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