Passed
Push — feature/initial-implementation ( fae671...591f29 )
by Fike
02:37
created

Registry   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 21
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 3 1
A get() 0 3 1
A register() 0 4 1
1
<?php
2
3
namespace AmaTeam\ElasticSearch\Entity\Descriptor;
4
5
use AmaTeam\ElasticSearch\API\Entity\Descriptor\RegistryInterface;
6
use AmaTeam\ElasticSearch\API\Entity\DescriptorInterface;
7
8
class Registry implements RegistryInterface
9
{
10
    /**
11
     * @var DescriptorInterface[]
12
     */
13
    private $descriptors = [];
14
15
    public function get(string $name): ?DescriptorInterface
16
    {
17
        return $this->descriptors[$name] ?? null;
18
    }
19
20
    public function has(string $name): bool
21
    {
22
        return isset($this->descriptors[$name]);
23
    }
24
25
    public function register(DescriptorInterface $descriptor): RegistryInterface
26
    {
27
        $this->descriptors[$descriptor->getName()] = $descriptor;
28
        return $this;
29
    }
30
}
31