Completed
Push — master ( 3f7aa1...a12959 )
by Mario
02:54
created

NativeResponseParser::parse()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
3
namespace Marek\Toggable\Http\Parser;
4
5
use Marek\Toggable\API\Http\Response\Response;
6
7
/**
8
 * Class NativeResponseParser
9
 * @package Marek\Toggable\Http\Parser
10
 */
11
class NativeResponseParser 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