AcceptorRegistry   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 35
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A get() 0 11 2
A keys() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Psi\Component\ResourceBrowser\Filter;
6
7
class AcceptorRegistry implements AcceptorRegistryInterface
8
{
9
    private $filters;
10
11
    public function __construct(array $filters)
12
    {
13
        array_map(function (AcceptorInterface $filter) {
0 ignored issues
show
Unused Code introduced by
The parameter $filter is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
14
        }, $filters);
15
16
        $this->filters = $filters;
17
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function get($name): AcceptorInterface
23
    {
24
        if (!isset($this->filters[$name])) {
25
            throw new \InvalidArgumentException(sprintf(
26
                'Unknown filter acceptor "%s". Known filter acceptors: "%s"',
27
                $name, implode('", "', array_keys($this->filters))
28
            ));
29
        }
30
31
        return $this->filters[$name];
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function keys(): array
38
    {
39
        return array_keys($this->filters);
40
    }
41
}
42