Passed
Pull Request — master (#44)
by Baptiste
02:25
created

PluginClientBuilder::addPlugin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php declare(strict_types=1);
2
namespace Behapi\Http;
3
4
use Http\Client\Common\Plugin;
5
use Http\Client\Common\PluginClient;
6
7
final class PluginClientBuilder
8
{
9
    /** @var Plugin[] */
10
    private $plugins;
11
12
    /** @var ?PluginClient */
13
    private $client;
14
15
    public function addPlugin(Plugin $plugin): void
16
    {
17
        $this->plugins[] = $plugin;
18
        $this->client = null;
19
    }
20
21
    public function createClient($client, array $options = []): PluginClient
22
    {
23
        if (null === $this->client) {
24
            $this->client = new PluginClient(
25
                $client,
26
                $this->plugins,
27
                $options
28
            );
29
        }
30
31
        return $this->client;
32
    }
33
}
34