Registry   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addFacet() 0 3 1
A getFacets() 0 3 1
A getFacetById() 0 7 2
1
<?php
2
3
/*
4
 * This file was created by developers working at BitBag
5
 * Do you need more information about us and what we do? Visit our https://bitbag.io website!
6
 * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7
*/
8
9
declare(strict_types=1);
10
11
namespace BitBag\SyliusElasticsearchPlugin\Facet;
12
13
final class Registry implements RegistryInterface
14
{
15
    /** @var FacetInterface[] */
16
    private $facets = [];
17
18
    public function addFacet(string $facetId, FacetInterface $facet): void
19
    {
20
        $this->facets[$facetId] = $facet;
21
    }
22
23
    /**
24
     * @return FacetInterface[]
25
     */
26
    public function getFacets(): array
27
    {
28
        return $this->facets;
29
    }
30
31
    public function getFacetById(string $facetId): FacetInterface
32
    {
33
        if (!array_key_exists($facetId, $this->facets)) {
34
            throw new FacetNotFoundException(sprintf('Cannot find facet with ID "%s" in registry.', $facetId));
35
        }
36
37
        return $this->facets[$facetId];
38
    }
39
}
40