Completed
Pull Request — master (#85)
by Romain
02:41
created

InsightsResponse   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
dl 0
loc 33
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 3 1
A parseResponse() 0 3 1
A setData() 0 5 4
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
    /**
19
     * @param array $response
20
     */
21
    protected function parseResponse(array $response): void
22 3
    {
23
        $this->setData($response);
24 3
    }
25 3
26
    /**
27
     * @return \Kerox\Messenger\Model\Data[]
28
     */
29
    public function getData(): array
30 3
    {
31
        return $this->data;
32 3
    }
33 3
34
    /**
35
     * @param array $response
36
     */
37
    private function setData(array $response): void
38 3
    {
39
        if (isset($response[self::DATA]) && !empty($response[self::DATA])) {
40 3
            foreach ($response[self::DATA] as $data) {
41
                $this->data[] = Data::create($data);
42
            }
43
        }
44
    }
45
}
46