Registry   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 37
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 6 1
A get() 0 9 1
1
<?php
2
3
namespace GBProd\ElasticsearchDataProviderBundle\DataProvider;
4
5
/**
6
 * Registry for DataProvider
7
 *
8
 * @author gbprod <[email protected]>
9
 */
10
class Registry
11
{
12
    /**
13
     * @var array<RegistryEntry>
14
     */
15
    private $entries = [];
16
17
    /**
18
     * Add a entry to the registry
19
     *
20
     * @param RegistryEntry $entry
21
     */
22 2
    public function add(RegistryEntry $entry)
23
    {
24 2
        $this->entries[] = $entry;
25
26 2
        return $this;
27
    }
28
29
    /**
30
     * Get entries for index and type
31
     *
32
     * @param string|null $index
33
     * @param string|null $type
34
     *
35
     * @return array<ProviderEntry>
36
     */
37 3
    public function get($index = null, $type = null)
38
    {
39 3
        return array_filter(
40 3
            $this->entries,
41 2
            function($entry) use ($index, $type) {
42 2
                return $entry->match($index, $type);
43
            }
44 3
        );
45
    }
46
}