Passed
Push — master ( a12ced...7e9047 )
by Michael
04:20
created

ObjectMapperHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 35
ccs 5
cts 7
cp 0.7143
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 4 1
A supports() 0 4 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Mikemirten\Bundle\JsonApiBundle\ObjectHandler;
5
6
use Mikemirten\Component\JsonApi\Document\ResourceObject;
7
use Mikemirten\Component\JsonApi\Mapper\ObjectMapper;
8
9
/**
10
 * Handler-bridge to the object-mapper of JsonAPI component.
11
 *
12
 * @package Mikemirten\Bundle\JsonApiBundle\ObjectHandler
13
 */
14
class ObjectMapperHandler implements ObjectHandlerInterface
15
{
16
    /**
17
     * JsonAPI resource object mapper
18
     *
19
     * @var ObjectMapper
20
     */
21
    protected $mapper;
22
23
    /**
24
     * ObjectMapperHandler constructor.
25
     *
26
     * @param ObjectMapper $mapper
27
     */
28 1
    public function __construct(ObjectMapper $mapper)
29
    {
30 1
        $this->mapper = $mapper;
31 1
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36 1
    public function handle($object): ResourceObject
37
    {
38 1
        return $this->mapper->toResource($object);
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function supports(string $class): bool
45
    {
46
        return true;
47
    }
48
}