RegistryResolver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 40
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A supports() 0 4 1
A resolve() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Paymaxi\FractalBundle\Resolver;
5
6
use League\Fractal\TransformerAbstract;
7
use Sylius\Component\Registry\ServiceRegistryInterface;
8
9
10
/**
11
 * Class RegistryResolver
12
 *
13
 * @package Paymaxi\FractalBundle\Resolver
14
 */
15
final class RegistryResolver implements ResolverInterface
16
{
17
    /** @var  ServiceRegistryInterface */
18
    private $registry;
19
20
    /**
21
     * RegistryResolver constructor.
22
     *
23
     * @param ServiceRegistryInterface $registry
24
     */
25
    public function __construct(ServiceRegistryInterface $registry)
26
    {
27
        $this->registry = $registry;
28
    }
29
30
    /**
31
     * @param string $class
32
     *
33
     * @param $resourceTransformer
34
     *
35
     * @return bool
36
     */
37
    public function supports(string $class, $resourceTransformer)
38
    {
39
        return $this->registry->has($class);
40
    }
41
42
    /**
43
     *
44
     * @param string $class
45
     *
46
     * @param $resourceTransformer
47
     *
48
     * @return TransformerAbstract
49
     */
50
    public function resolve(string $class, $resourceTransformer)
51
    {
52
        return $this->registry->get($class);
53
    }
54
}