InsightsResponse::parseResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Response;
6
7
use Kerox\Messenger\Model\Data;
8
9
class InsightsResponse extends AbstractResponse
10
{
11
    private const DATA = 'data';
12
13
    /**
14
     * @var \Kerox\Messenger\Model\Data[]
15
     */
16
    protected $data = [];
17
18 1
    protected function parseResponse(array $response): void
19
    {
20 1
        $this->setData($response);
21 1
    }
22
23
    /**
24
     * @return \Kerox\Messenger\Model\Data[]
25
     */
26 1
    public function getData(): array
27
    {
28 1
        return $this->data;
29
    }
30
31 1
    private function setData(array $response): void
32
    {
33 1
        if (isset($response[self::DATA]) && !empty($response[self::DATA])) {
34 1
            foreach ($response[self::DATA] as $data) {
35 1
                $this->data[] = Data::create($data);
36
            }
37
        }
38 1
    }
39
}
40