1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Kerox\Messenger\Model; |
6
|
|
|
|
7
|
|
|
use Kerox\Messenger\Model\Data\Value; |
8
|
|
|
|
9
|
|
|
class Data |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @var string|null |
13
|
|
|
*/ |
14
|
|
|
protected $name; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var string|null |
18
|
|
|
*/ |
19
|
|
|
protected $period; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var array |
23
|
|
|
*/ |
24
|
|
|
protected $values = []; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var string|null |
28
|
|
|
*/ |
29
|
|
|
protected $title; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string|null |
33
|
|
|
*/ |
34
|
|
|
protected $description; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string|null |
38
|
|
|
*/ |
39
|
|
|
protected $id; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string|null |
43
|
|
|
*/ |
44
|
|
|
protected $tag; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var string|null |
48
|
|
|
*/ |
49
|
|
|
protected $profilePictureUrl; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var array |
53
|
|
|
*/ |
54
|
|
|
protected $data; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Data constructor. |
58
|
|
|
*/ |
59
|
4 |
|
public function __construct(array $data) |
60
|
|
|
{ |
61
|
4 |
|
$this->name = $data['name'] ?? null; |
62
|
4 |
|
$this->period = $data['period'] ?? null; |
63
|
4 |
|
$this->title = $data['title'] ?? null; |
64
|
4 |
|
$this->description = $data['description'] ?? null; |
65
|
4 |
|
$this->id = $data['id'] ?? null; |
66
|
4 |
|
$this->tag = $data['tag'] ?? null; |
67
|
4 |
|
$this->profilePictureUrl = $data['profile_picture_url'] ?? null; |
68
|
|
|
|
69
|
4 |
|
$this->setValues($data); |
70
|
4 |
|
} |
71
|
|
|
|
72
|
1 |
|
public function getName(): ?string |
73
|
|
|
{ |
74
|
1 |
|
return $this->name; |
75
|
|
|
} |
76
|
|
|
|
77
|
1 |
|
public function getPeriod(): ?string |
78
|
|
|
{ |
79
|
1 |
|
return $this->period; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return \Kerox\Messenger\Model\Data\Value[] |
84
|
|
|
*/ |
85
|
1 |
|
public function getValues(): array |
86
|
|
|
{ |
87
|
1 |
|
return $this->values; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return \Kerox\Messenger\Model\Data |
92
|
|
|
*/ |
93
|
4 |
|
public function setValues(array $data): self |
94
|
|
|
{ |
95
|
4 |
|
if (isset($data['values']) && !empty($data['values'])) { |
96
|
2 |
|
foreach ($data['values'] as $value) { |
97
|
2 |
|
$this->values[] = Value::create($value['value'], $value['end_time']); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|
101
|
4 |
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
1 |
|
public function getTitle(): ?string |
105
|
|
|
{ |
106
|
1 |
|
return $this->title; |
107
|
|
|
} |
108
|
|
|
|
109
|
1 |
|
public function getDescription(): ?string |
110
|
|
|
{ |
111
|
1 |
|
return $this->description; |
112
|
|
|
} |
113
|
|
|
|
114
|
1 |
|
public function getId(): ?string |
115
|
|
|
{ |
116
|
1 |
|
return $this->id; |
117
|
|
|
} |
118
|
|
|
|
119
|
1 |
|
public function getTag(): ?string |
120
|
|
|
{ |
121
|
1 |
|
return $this->tag; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function getProfilePictureUrl(): ?string |
125
|
|
|
{ |
126
|
|
|
return $this->profilePictureUrl; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return \Kerox\Messenger\Model\Data |
131
|
|
|
*/ |
132
|
3 |
|
public static function create(array $data): self |
133
|
|
|
{ |
134
|
3 |
|
return new self($data); |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|