Completed
Push — 3.x ( e32815...7c4255 )
by Ryota
10:41 queued 09:27
created

ClientFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Polidog\Chatwork\Client;
6
7
final class ClientFactory
8
{
9
    /**
10
     * HttpOptions.
11
     *
12
     * @var array
13
     */
14
    private static $httpOptions = [
15
        'base_uri' => 'https://api.chatwork.com/',
16
        'defaults' => [
17
            'timeout' => 60,
18
            'debug' => false,
19
        ],
20
        'headers' => [
21
            'User-Agent' => 'php-chatwork-api v2',
22
            'Accept' => 'application/json',
23
        ],
24
    ];
25
26
    public static function create(string $token, string $version, array $httpOptions = []): ClientInterface
27
    {
28
        $httpOptions = array_merge(self::$httpOptions, $httpOptions);
29
30
        return new Client(new \GuzzleHttp\Client($httpOptions), $token, $version);
31
    }
32
}
33