ClientRegistry::set()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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