ClientRegistry::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 3
cts 4
cp 0.75
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
crap 2.0625
1
<?php
2
3
namespace Vox\Webservice;
4
5
use GuzzleHttp\ClientInterface;
6
use RuntimeException;
7
8
/**
9
 * @author Jhonatan Teixeira <[email protected]>
10
 */
11
class ClientRegistry implements ClientRegistryInterface
12
{
13
    private $clients = [];
14
    
15 31
    public function get(string $name): ClientInterface
16
    {
17 31
        if (!isset($this->clients[$name])) {
18
            throw new RuntimeException("no client registered for $name");
19
        }
20
        
21 31
        return $this->clients[$name];
22
    }
23
24 34
    public function set(string $name, ClientInterface $client)
25
    {
26 34
        $this->clients[$name] = $client;
27
        
28 34
        return $this;
29
    }
30
}
31