1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the PhpMob package. |
5
|
|
|
* |
6
|
|
|
* (c) Ishmael Doss <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace PhpMob\Settings\Model; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @author Ishmael Doss <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class Setting implements SettingInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var int |
23
|
|
|
*/ |
24
|
|
|
protected $id; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
private $section; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $key; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
protected $value; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
protected $owner; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var \DateTimeInterface|null |
48
|
|
|
*/ |
49
|
|
|
protected $createdAt; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var \DateTimeInterface|null |
53
|
|
|
*/ |
54
|
|
|
protected $updatedAt; |
55
|
|
|
|
56
|
3 |
|
public function __construct() |
57
|
|
|
{ |
58
|
3 |
|
$this->createdAt = new \DateTime(); |
59
|
3 |
|
$this->updatedAt = new \DateTime(); |
60
|
3 |
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* {@inheritdoc} |
64
|
|
|
*/ |
65
|
|
|
public function getId() |
66
|
|
|
{ |
67
|
|
|
return $this->id; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* {@inheritdoc} |
72
|
|
|
*/ |
73
|
3 |
|
public function getSection(): string |
74
|
|
|
{ |
75
|
3 |
|
return $this->section; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* {@inheritdoc} |
80
|
|
|
*/ |
81
|
3 |
|
public function setSection(string $section): void |
82
|
|
|
{ |
83
|
3 |
|
$this->section = $section; |
84
|
3 |
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* {@inheritdoc} |
88
|
|
|
*/ |
89
|
3 |
|
public function getKey(): string |
90
|
|
|
{ |
91
|
3 |
|
return $this->key; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* {@inheritdoc} |
96
|
|
|
*/ |
97
|
3 |
|
public function setKey(string $key): void |
98
|
|
|
{ |
99
|
3 |
|
$this->key = $key; |
100
|
3 |
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* {@inheritdoc} |
104
|
|
|
*/ |
105
|
1 |
|
public function getValue(): string |
106
|
|
|
{ |
107
|
1 |
|
return (string) $this->value; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* {@inheritdoc} |
112
|
|
|
*/ |
113
|
3 |
|
public function setValue(?string $value): void |
114
|
|
|
{ |
115
|
3 |
|
$this->value = $value; |
116
|
3 |
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* {@inheritdoc} |
120
|
|
|
*/ |
121
|
3 |
|
public function getOwner(): ?string |
122
|
|
|
{ |
123
|
3 |
|
return $this->owner; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* {@inheritdoc} |
128
|
|
|
*/ |
129
|
3 |
|
public function setOwner(?string $owner): void |
130
|
|
|
{ |
131
|
3 |
|
$this->owner = $owner; |
132
|
3 |
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @return \DateTimeInterface|null |
136
|
|
|
*/ |
137
|
|
|
public function getCreatedAt(): ?\DateTimeInterface |
138
|
|
|
{ |
139
|
|
|
return $this->createdAt; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @param \DateTimeInterface|null $createdAt |
144
|
|
|
*/ |
145
|
|
|
public function setCreatedAt(?\DateTimeInterface $createdAt): void |
146
|
|
|
{ |
147
|
|
|
$this->createdAt = $createdAt; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @return \DateTimeInterface|null |
152
|
|
|
*/ |
153
|
|
|
public function getUpdatedAt(): ?\DateTimeInterface |
154
|
|
|
{ |
155
|
|
|
return $this->updatedAt; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @param \DateTimeInterface|null $updatedAt |
160
|
|
|
*/ |
161
|
|
|
public function setUpdatedAt(?\DateTimeInterface $updatedAt): void |
162
|
|
|
{ |
163
|
|
|
$this->updatedAt = $updatedAt; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* {@inheritdoc} |
168
|
|
|
*/ |
169
|
3 |
|
public function isEqual(SettingInterface $setting) |
170
|
|
|
{ |
171
|
3 |
|
return $this->isEquals($setting->getSection(), $setting->getKey(), $setting->getOwner()); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* {@inheritdoc} |
176
|
|
|
*/ |
177
|
3 |
|
public function isEquals(string $section, string $key, ?string $owner = null) |
178
|
|
|
{ |
179
|
3 |
|
return $section === $this->getSection() |
180
|
3 |
|
&& $key === $this->getKey() |
181
|
3 |
|
&& $owner === $this->getOwner(); |
182
|
|
|
} |
183
|
|
|
} |
184
|
|
|
|