Completed
Push — master ( 1be44d...449b6f )
by Artem
02:21
created

HttpFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 18
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A createHttpClient() 0 16 1
1
<?php declare(strict_types=1);
2
3
namespace Gockets\Factory;
4
5
use Gockets\Model\Params;
6
use GuzzleHttp\Client as HttpClient;
7
8
/**
9
 * Http Client Factory
10
 *
11
 * Responsible for creating instance of HTTP client.
12
 */
13
class HttpFactory
14
{
15
    public static function createHttpClient(Params $params): HttpClient
16
    {
17
        $baseUri = "{$params->getHost()}:{$params->getPort()}/";
18
19
        // Communications through JSON
20
        $headers = [
21
            'Accept' => 'application/json',
22
            'Content-Type' => 'application/json',
23
        ];
24
25
        return new \GuzzleHttp\Client([
26
            'base_uri' => $baseUri,
27
            'defaults' => [
28
                'headers' => $headers,
29
            ],
30
            'http_errors' => false,
31
        ]);
32
    }
33
}
34