StorageRegistry   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 24
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getStorage() 0 7 2
A register() 0 3 1
1
<?php
2
3
namespace Lamoda\Metric\Storage;
4
5
/**
6
 * @internal
7
 */
8
final class StorageRegistry
9
{
10
    /** @var array MetricStorageInterface[] */
11
    private $storages = [];
12
13 1
    public function register(string $name, MetricStorageInterface $storage): void
14
    {
15 1
        $this->storages[$name] = $storage;
16 1
    }
17
18
    /**
19
     * @param string $name
20
     *
21
     * @return MetricStorageInterface
22
     *
23
     * @throws \OutOfBoundsException
24
     */
25 2
    public function getStorage(string $name): MetricStorageInterface
26
    {
27 2
        if (!array_key_exists($name, $this->storages)) {
28 1
            throw new \OutOfBoundsException('Unknown storage in registry: ' . $name);
29
        }
30
31 1
        return $this->storages[$name];
32
    }
33
}
34