Completed
Push — master ( d02ce0...14668b )
by Zbigniew
14:57
created

ArrayTransformer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
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 transform() 0 4 1
A isSupportedResponseFormat() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the zibios/wrike-php-library 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\WrikePhpLibrary\Transformer\Response\Json;
13
14
use Zibios\WrikePhpLibrary\Enum\Api\ResponseFormatEnum;
15
use Zibios\WrikePhpLibrary\Transformer\ResponseTransformerInterface;
16
17
/**
18
 * Array Transformer for JSON string response from HTTP Client.
19
 */
20
class ArrayTransformer implements ResponseTransformerInterface
21
{
22
    /**
23
     * @param string $responseFormat
24
     *
25
     * @return bool
26
     */
27 1
    public function isSupportedResponseFormat($responseFormat)
28
    {
29 1
        return $responseFormat === ResponseFormatEnum::JSON_BODY;
30
    }
31
32
    /**
33
     * @param mixed  $response
34
     * @param string $resourceClass
35
     *
36
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
37
     *
38
     * @throws \InvalidArgumentException
39
     * @throws \RuntimeException
40
     *
41
     * @return array
42
     */
43 1
    public function transform($response, $resourceClass)
44
    {
45 1
        return json_decode($response, true);
46
    }
47
}
48