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