InsightsResponse   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 31
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A parseResponse() 0 4 1
A getData() 0 4 1
A setData() 0 8 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 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