ClientBuilder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 33
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 9 1
A buildWithOAuth2Provider() 0 20 1
1
<?php
2
3
namespace Softonic\GraphQL;
4
5
use League\OAuth2\Client\Provider\AbstractProvider as OAuth2Provider;
6
use Psr\Cache\CacheItemPoolInterface as Cache;
7
8
class ClientBuilder
9
{
10 4
    public static function build(string $endpoint, array $guzzleOptions = []): Client
11
    {
12 4
        $guzzleOptions = array_merge(['base_uri' => $endpoint], $guzzleOptions);
13
14 4
        return new \Softonic\GraphQL\Client(
15 4
            new \GuzzleHttp\Client($guzzleOptions),
16 4
            new \Softonic\GraphQL\ResponseBuilder()
17
        );
18
    }
19
20 4
    public static function buildWithOAuth2Provider(
21
        string $endpoint,
22
        OAuth2Provider $oauthProvider,
23
        array $tokenOptions,
24
        Cache $cache,
25
        array $guzzleOptions = []
26
    ): Client {
27 4
        $guzzleOptions = array_merge(['base_uri' => $endpoint], $guzzleOptions);
28
29
30 4
        return new \Softonic\GraphQL\Client(
31 4
            \Softonic\OAuth2\Guzzle\Middleware\ClientBuilder::build(
32 4
                $oauthProvider,
33 2
                $tokenOptions,
34 2
                $cache,
35 2
                $guzzleOptions
36
            ),
37 4
            new \Softonic\GraphQL\ResponseBuilder()
38
        );
39
    }
40
}
41