Passed
Push — master ( 75f6ef...2d6bc8 )
by Siim
10:44
created

BaseSaveDto   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A populate() 0 10 4
A toArray() 0 6 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: siim
5
 * Date: 6.02.19
6
 * Time: 8:12
7
 */
8
9
namespace Sf4\Api\Dto\Response;
10
11
class BaseSaveDto extends AbstractResponseSaveDto
12
{
13
14
    /**
15
     * @param array|object|null $data
16
     */
17
    public function populate(array $data): void
18
    {
19
        if (isset($data[static::FIELD_STATUS])) {
20
            $this->setStatus($data[static::FIELD_STATUS]);
21
        }
22
        if (isset($data[static::FIELD_MESSAGE])) {
23
            $this->setMessage($data[static::FIELD_MESSAGE]);
24
        }
25
        if (isset($data[static::FIELD_NOTIFICATION])) {
26
            $this->setNotification($data[static::FIELD_NOTIFICATION]);
27
        }
28
    }
29
30
    /**
31
     * @return array
32
     */
33
    public function toArray(): array
34
    {
35
        return [
36
            static::FIELD_STATUS => $this->getStatus(),
37
            static::FIELD_MESSAGE => $this->getMessage(),
38
            static::FIELD_NOTIFICATION => $this->getNotification()->toArray()
39
        ];
40
    }
41
}
42