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

ClientFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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