1
|
|
|
<?php |
2
|
|
|
namespace Fwolf\Util\Uuid; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* UUID explanation DTO |
6
|
|
|
* |
7
|
|
|
* Why not store UUID as an object contain several parts as properties ? |
8
|
|
|
* - UUID generator need speed |
9
|
|
|
* - UUID explain is not widely needed |
10
|
|
|
* |
11
|
|
|
* @copyright Copyright 2016 Fwolf |
12
|
|
|
* @license http://opensource.org/licenses/MIT MIT |
13
|
|
|
*/ |
14
|
|
|
class Explanation |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* Array key for explain result |
18
|
|
|
*/ |
19
|
|
|
const COL_SECOND = 'second'; |
20
|
|
|
|
21
|
|
|
const COL_MICROSECOND = 'microSecond'; |
22
|
|
|
|
23
|
|
|
const COL_GROUP = 'group'; |
24
|
|
|
|
25
|
|
|
const COL_CUSTOM = 'custom'; |
26
|
|
|
|
27
|
|
|
const COL_RANDOM = 'random'; |
28
|
|
|
|
29
|
|
|
const COL_CHECK_DIGIT = 'checkDigit'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Is verify success |
33
|
|
|
*/ |
34
|
|
|
const COL_VERIFIED = 'verified'; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
protected $checkDigit = ''; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
protected $custom = ''; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
protected $group = ''; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var string |
53
|
|
|
*/ |
54
|
|
|
protected $microsecond = ''; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var string |
58
|
|
|
*/ |
59
|
|
|
protected $random = ''; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var string |
63
|
|
|
*/ |
64
|
|
|
protected $second = ''; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @var bool |
68
|
|
|
*/ |
69
|
|
|
protected $verified = true; |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return string |
74
|
|
|
*/ |
75
|
|
|
public function getCheckDigit() |
76
|
|
|
{ |
77
|
|
|
return $this->checkDigit; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return string |
83
|
|
|
*/ |
84
|
|
|
public function getCustom() |
85
|
|
|
{ |
86
|
|
|
return $this->custom; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return string |
92
|
|
|
*/ |
93
|
|
|
public function getGroup() |
94
|
|
|
{ |
95
|
|
|
return $this->group; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return string |
101
|
|
|
*/ |
102
|
|
|
public function getMicrosecond() |
103
|
|
|
{ |
104
|
|
|
return $this->microsecond; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return string |
110
|
|
|
*/ |
111
|
|
|
public function getRandom() |
112
|
|
|
{ |
113
|
|
|
return $this->random; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return string |
119
|
|
|
*/ |
120
|
|
|
public function getSecond() |
121
|
|
|
{ |
122
|
|
|
return $this->second; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @return boolean |
128
|
|
|
*/ |
129
|
|
|
public function isVerified() |
130
|
|
|
{ |
131
|
|
|
return $this->verified; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @param string $checkDigit |
137
|
|
|
* @return $this |
138
|
|
|
*/ |
139
|
|
|
public function setCheckDigit($checkDigit) |
140
|
|
|
{ |
141
|
|
|
$this->checkDigit = $checkDigit; |
142
|
|
|
|
143
|
|
|
return $this; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @param string $custom |
149
|
|
|
* @return $this |
150
|
|
|
*/ |
151
|
|
|
public function setCustom($custom) |
152
|
|
|
{ |
153
|
|
|
$this->custom = $custom; |
154
|
|
|
|
155
|
|
|
return $this; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @param string $group |
161
|
|
|
* @return $this |
162
|
|
|
*/ |
163
|
|
|
public function setGroup($group) |
164
|
|
|
{ |
165
|
|
|
$this->group = $group; |
166
|
|
|
|
167
|
|
|
return $this; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @param string $microsecond |
173
|
|
|
* @return $this |
174
|
|
|
*/ |
175
|
|
|
public function setMicrosecond($microsecond) |
176
|
|
|
{ |
177
|
|
|
$this->microsecond = $microsecond; |
178
|
|
|
|
179
|
|
|
return $this; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @param string $random |
185
|
|
|
* @return $this |
186
|
|
|
*/ |
187
|
|
|
public function setRandom($random) |
188
|
|
|
{ |
189
|
|
|
$this->random = $random; |
190
|
|
|
|
191
|
|
|
return $this; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @param string $second |
197
|
|
|
* @return $this |
198
|
|
|
*/ |
199
|
|
|
public function setSecond($second) |
200
|
|
|
{ |
201
|
|
|
$this->second = $second; |
202
|
|
|
|
203
|
|
|
return $this; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* @param boolean $verified |
209
|
|
|
* @return $this |
210
|
|
|
*/ |
211
|
|
|
public function setVerified($verified) |
212
|
|
|
{ |
213
|
|
|
$this->verified = $verified; |
214
|
|
|
|
215
|
|
|
return $this; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @return array |
221
|
|
|
*/ |
222
|
|
|
public function toArray() |
223
|
|
|
{ |
224
|
|
|
return [ |
225
|
|
|
static::COL_SECOND => $this->getSecond(), |
226
|
|
|
static::COL_MICROSECOND => $this->getMicrosecond(), |
227
|
|
|
static::COL_GROUP => $this->getGroup(), |
228
|
|
|
static::COL_CUSTOM => $this->getCustom(), |
229
|
|
|
static::COL_RANDOM => $this->getRandom(), |
230
|
|
|
static::COL_CHECK_DIGIT => $this->getCheckDigit(), |
231
|
|
|
static::COL_VERIFIED => $this->isVerified(), |
232
|
|
|
]; |
233
|
|
|
} |
234
|
|
|
} |
235
|
|
|
|