Passed
Pull Request — master (#5)
by Igor
03:05
created

ClientFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 6
c 1
b 0
f 1
dl 0
loc 16
ccs 7
cts 7
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createClient() 0 6 1
A __construct() 0 3 1
1
<?php
2
/*
3
 * This file is part of JSON RPC Client.
4
 *
5
 * (c) Igor Lazarev <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Strider2038\JsonRpcClient;
12
13
use Psr\Log\LoggerInterface;
14
use Strider2038\JsonRpcClient\Configuration\GeneralOptions;
15
use Strider2038\JsonRpcClient\Transport\TransportFactory;
16
17
/**
18
 * @experimental API may be changed
19
 *
20
 * @author Igor Lazarev <[email protected]>
21
 */
22
class ClientFactory
23
{
24
    /** @var TransportFactory */
25
    private $transportFactory;
26
27 15
    public function __construct(LoggerInterface $logger = null)
28
    {
29 15
        $this->transportFactory = new TransportFactory($logger);
30 15
    }
31
32 15
    public function createClient(string $connection, array $options = []): ClientInterface
33
    {
34 15
        $transport = $this->transportFactory->createTransport($connection, GeneralOptions::createFromArray($options));
35 14
        $clientBuilder = new ClientBuilder($transport);
36
37 14
        return $clientBuilder->getClient();
38
    }
39
}
40