Completed
Branch master (c90d5b)
by Riccardo
02:51
created

ClientBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
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 31
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 7 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 2
    public static function build(string $endpoint)
11
    {
12 2
        return new \Softonic\GraphQL\Client(
13 2
            new \GuzzleHttp\Client(['base_uri' => $endpoint]),
14 2
            new \Softonic\GraphQL\ResponseBuilder()
15
        );
16
    }
17
18 2
    public static function buildWithOAuth2Provider(
19
        string $endpoint,
20
        OAuth2Provider $oauthProvider,
21
        array $tokenOptions,
22
        Cache $cache
23
    ): Client {
24
        $guzzleOptions = [
25 2
            'base_uri' => $endpoint,
26
        ];
27
28 2
        return new \Softonic\GraphQL\Client(
29 2
            \Softonic\OAuth2\Guzzle\Middleware\ClientBuilder::build(
30 1
                $oauthProvider,
31 1
                $tokenOptions,
32 1
                $cache,
33 1
                $guzzleOptions
34
            ),
35 2
            new \Softonic\GraphQL\ResponseBuilder()
36
        );
37
    }
38
}
39