Completed
Pull Request — master (#30)
by Romain
02:57 queued 31s
created

Data::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace Kerox\Messenger\Model;
3
4
use Kerox\Messenger\Model\Data\Value;
5
6
class Data
7
{
8
9
    /**
10
     * @var array
11
     */
12
    protected $data;
13
14
    /**
15
     * Data constructor.
16
     *
17
     * @param array $data
18
     */
19 4
    public function __construct(array $data)
20
    {
21 4
        $this->data = $data;
22 4
    }
23
24
    /**
25
     * @return string
26
     */
27 1
    public function getName(): string
28
    {
29 1
        return $this->data['name'] ?? '';
30
    }
31
32
    /**
33
     * @return string
34
     */
35 1
    public function getPeriod(): string
36
    {
37 1
        return $this->data['period'] ?? '';
38
    }
39
40
    /**
41
     * @return \Kerox\Messenger\Model\Data\Value[]
42
     */
43 1
    public function getValues(): array
44
    {
45 1
        $values = [];
46 1
        if (isset($this->data['values']) && !empty($this->data['values'])) {
47 1
            foreach ($this->data['values'] as $value) {
48 1
                $values[] = new Value($value['value'], $value['end_time']);
49
            }
50
        }
51
52 1
        return $values;
53
    }
54
55
    /**
56
     * @return string
57
     */
58 1
    public function getTitle(): string
59
    {
60 1
        return $this->data['title'] ?? '';
61
    }
62
63
    /**
64
     * @return string
65
     */
66 1
    public function getDescription(): string
67
    {
68 1
        return $this->data['description'] ?? '';
69
    }
70
71
    /**
72
     * @return string
73
     */
74 1
    public function getId(): string
75
    {
76 1
        return $this->data['id'] ?? '';
77
    }
78
}
79