ClientRegistry   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 18
ccs 6
cts 7
cp 0.8571
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 7 2
A set() 0 5 1
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