Completed
Push — master ( f87b82...3f7aa1 )
by Mario
02:46
created

ResponseParser::parse()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
ccs 0
cts 7
cp 0
rs 9.4285
cc 2
eloc 7
nc 2
nop 1
crap 6
1
<?php
2
3
namespace Marek\Toggable\Http\Parser;
4
5
use Marek\Toggable\API\Http\Response\Response;
6
7
/**
8
 * Class ResponseParser
9
 * @package Marek\Toggable\Http\Parser
10
 */
11
class ResponseParser implements HttpResponseParserInterface
12
{
13
    /**
14
     * @inheritDoc
15
     */
16
    public function parse(array $data)
17
    {
18
        $body = json_decode($data['data'], true);
19
20
        $statusCode = empty($data['metadata']['wrapper_data'][0]) ? 0 : $data['metadata']['wrapper_data'][0];
21
22
        return new Response(
23
            array(
24
                'statusCode' => $statusCode,
25
                'body' => $body,
26
            )
27
        );
28
    }
29
}
30