RegistryResolver::resolve()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 2
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
}