ResourceModelTransformer   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 12 1
1
<?php
2
3
/*
4
 * This file is part of the zibios/wrike-php-jmsserializer package.
5
 *
6
 * (c) Zbigniew Ślązak
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zibios\WrikePhpJmsserializer\Transformer\Response;
13
14
use Psr\Http\Message\ResponseInterface;
15
use Zibios\WrikePhpJmsserializer\Model\ResourceModelInterface;
16
use Zibios\WrikePhpJmsserializer\Model\ResponseModelInterface;
17
18
/**
19
 * Resource Model Transformer.
20
 */
21
class ResourceModelTransformer extends AbstractResponseTransformer
22
{
23
    /**
24
     * @param ResponseInterface $response
25
     * @param string            $resourceClass
26
     *
27
     * @throws \InvalidArgumentException
28
     * @throws \RuntimeException
29
     *
30
     * @return array|ResourceModelInterface[]|null
31
     */
32 21
    public function transform($response, $resourceClass)
33
    {
34 21
        $stringBody = $this->transformToStringBody($response);
35
        /** @var ResponseModelInterface $responseModel */
36 19
        $responseModel = $this->serializer->deserialize(
37 19
            $stringBody,
38 19
            $this->getModelClassForResource($resourceClass),
39 17
            'json'
40
        );
41
42 17
        return $responseModel->getData();
43
    }
44
}
45