PathAttributeResolverRegistry   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 28
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A registerPathAttributeResolver() 0 4 1
A getResolverByType() 0 10 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Paysera\Bundle\ApiBundle\Service\PathAttributeResolver;
5
6
use InvalidArgumentException;
7
8
class PathAttributeResolverRegistry
9
{
10
    /**
11
     * @var array|PathAttributeResolverInterface[] by type
12
     */
13
    private $resolvers;
14
15 96
    public function __construct()
16
    {
17 96
        $this->resolvers = [];
18 96
    }
19
20 96
    public function registerPathAttributeResolver(PathAttributeResolverInterface $resolver, string $type)
21
    {
22 96
        $this->resolvers[$type] = $resolver;
23 96
    }
24
25 96
    public function getResolverByType(string $type): PathAttributeResolverInterface
26
    {
27 96
        if (!isset($this->resolvers[$type])) {
28
            throw new InvalidArgumentException(
29
                sprintf('No such path attribute resolver registered: "%s"', $type)
30
            );
31
        }
32
33 96
        return $this->resolvers[$type];
34
    }
35
}
36