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

Data   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 1
dl 0
loc 73
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getName() 0 4 1
A getPeriod() 0 4 1
A getValues() 0 11 4
A getTitle() 0 4 1
A getDescription() 0 4 1
A getId() 0 4 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