ContainerAwareResolver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 4 2
A resolve() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Paymaxi\FractalBundle\Resolver;
5
6
7
use League\Fractal\TransformerAbstract;
8
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
9
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
10
11
/**
12
 * Class ContainerAwareResolver
13
 *
14
 * @package Paymaxi\FractalBundle\Resolver
15
 */
16
final class ContainerAwareResolver implements ResolverInterface, ContainerAwareInterface
17
{
18
    use ContainerAwareTrait;
19
20
    /**
21
     * @param string $class
22
     *
23
     * @param $resourceTransformer
24
     *
25
     * @return bool
26
     */
27 4
    public function supports(string $class, $resourceTransformer)
28
    {
29 4
        return \is_string($resourceTransformer) && $this->container->has($resourceTransformer);
30
    }
31
32
    /**
33
     * @param string $class
34
     *
35
     * @param $resourceTransformer
36
     *
37
     * @return TransformerAbstract|object
38
     */
39 4
    public function resolve(string $class, $resourceTransformer)
40
    {
41 4
        return $this->container->get($resourceTransformer);
42
    }
43
}