8
8
class Reader
9
9
{
10
10
private $ fetchNew = false ;
11
- private $ database ;
12
- private $ filemtime ;
11
+
12
+ private static $ database ;
13
+ private static $ filemtime ;
13
14
14
15
public $ valid = false ;
15
16
public $ nik ;
@@ -56,20 +57,6 @@ public function setNik(string $nik)
56
57
{
57
58
$ this ->nik = $ nik ;
58
59
59
- if (
60
- ! is_string ($ this ->nik )
61
- || ! preg_match ("/^[0-9]+$/is " , $ this ->nik )
62
- || ! strlen ($ this ->nik ) === 16
63
- ) {
64
- // throw new Exceptions\InvalidNikNumberException(sprintf(
65
- // 'NIK number should be a 16-digit numeric string. Got: %s (%d)',
66
- // gettype($nik),
67
- // strlen($nik)
68
- // ));
69
-
70
- $ this ->valid = false ;
71
- }
72
-
73
60
return $ this ;
74
61
}
75
62
@@ -130,7 +117,7 @@ public function setDatabase(string $file)
130
117
));
131
118
}
132
119
133
- if ($ this -> filemtime <= filemtime ($ file )) {
120
+ if (static :: $ filemtime <= filemtime ($ file )) {
134
121
$ database = file_get_contents ($ file );
135
122
$ database = json_decode ($ database );
136
123
@@ -142,8 +129,8 @@ public function setDatabase(string $file)
142
129
));
143
130
}
144
131
145
- $ this -> database = $ database ;
146
- $ this -> filemtime = filemtime ($ file );
132
+ static :: $ database = $ database ;
133
+ static :: $ filemtime = filemtime ($ file );
147
134
}
148
135
149
136
return $ this ;
@@ -163,8 +150,8 @@ public function getProvince()
163
150
$ this ->province_id = substr ($ this ->nik , 0 , 2 );
164
151
165
152
return $ this ->province = (
166
- isset ($ this -> database ->provinces ->{$ this ->province_id })
167
- ? $ this -> database ->provinces ->{$ this ->province_id }
153
+ isset (static :: $ database ->provinces ->{$ this ->province_id })
154
+ ? static :: $ database ->provinces ->{$ this ->province_id }
168
155
: null
169
156
);
170
157
}
@@ -183,8 +170,8 @@ public function getCity()
183
170
$ this ->city_id = substr ($ this ->nik , 0 , 4 );
184
171
185
172
return $ this ->city = (
186
- isset ($ this -> database ->cities ->{$ this ->city_id })
187
- ? $ this -> database ->cities ->{$ this ->city_id }
173
+ isset (static :: $ database ->cities ->{$ this ->city_id })
174
+ ? static :: $ database ->cities ->{$ this ->city_id }
188
175
: null
189
176
);
190
177
}
@@ -203,8 +190,8 @@ public function getSubdistrict()
203
190
$ this ->subdistrict_id = substr ($ this ->nik , 0 , 6 );
204
191
205
192
$ this ->subdistrict = (
206
- isset ($ this -> database ->subdistricts ->{$ this ->subdistrict_id })
207
- ? $ this -> database ->subdistricts ->{$ this ->subdistrict_id }
193
+ isset (static :: $ database ->subdistricts ->{$ this ->subdistrict_id })
194
+ ? static :: $ database ->subdistricts ->{$ this ->subdistrict_id }
208
195
: null
209
196
);
210
197
@@ -230,8 +217,8 @@ public function getPostalCode()
230
217
$ code = substr ($ this ->nik , 0 , 6 );
231
218
232
219
$ subdistrict = (
233
- isset ($ this -> database ->subdistricts ->{$ code })
234
- ? $ this -> database ->subdistricts ->{$ code }
220
+ isset (static :: $ database ->subdistricts ->{$ code })
221
+ ? static :: $ database ->subdistricts ->{$ code }
235
222
: null
236
223
);
237
224
@@ -339,7 +326,7 @@ public function getZodiac()
339
326
$ day = $ day - 40 ;
340
327
}
341
328
342
- foreach ($ this -> database ->zodiacs as $ data ) {
329
+ foreach (static :: $ database ->zodiacs as $ data ) {
343
330
$ range = explode ('- ' , $ data [0 ]);
344
331
$ rangeStart = explode ('/ ' , $ range [0 ]);
345
332
$ rangeEnd = explode ('/ ' , $ range [1 ]);
0 commit comments