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

Registry::has()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
eloc 1
nc 1
nop 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