23
23
* @property PDO $pdo
24
24
*
25
25
*/
26
- class Converter {
26
+ class Converter
27
+ {
28
+ /**
29
+ * Parser version.
30
+ */
27
31
const VERSION = '1 ' ;
28
32
29
33
/**
@@ -195,7 +199,8 @@ class Converter {
195
199
*
196
200
* @param string $tmp
197
201
*/
198
- public function __construct ($ tmp = null ) {
202
+ public function __construct ($ tmp = null )
203
+ {
199
204
$ this ->errors = array ();
200
205
$ this ->temporaryDir = (is_dir ($ tmp ))?$ tmp :sys_get_temp_dir ();
201
206
}
@@ -205,7 +210,8 @@ public function __construct($tmp = null) {
205
210
*
206
211
* @return array
207
212
*/
208
- public function getErrors () {
213
+ public function getErrors ()
214
+ {
209
215
return $ this ->errors ;
210
216
}
211
217
@@ -214,7 +220,8 @@ public function getErrors() {
214
220
*
215
221
* @param string $author
216
222
*/
217
- public function setAuthor ($ author ) {
223
+ public function setAuthor ($ author )
224
+ {
218
225
if (mb_strlen ($ author ) > 64 ) $ author = mb_substr ($ author ,0 ,64 );
219
226
$ this ->author = $ author ;
220
227
}
@@ -224,7 +231,8 @@ public function setAuthor($author) {
224
231
*
225
232
* @param string $license
226
233
*/
227
- public function setLicense ($ license ) {
234
+ public function setLicense ($ license )
235
+ {
228
236
$ this ->license = $ license ;
229
237
}
230
238
@@ -239,7 +247,8 @@ public function setLicense($license) {
239
247
* @param string $enclosure
240
248
* @param string $escape
241
249
*/
242
- public function addCSV ($ name ,$ file ,$ ignoreFirstRows =true ,$ encoding ='UTF-8 ' ,$ delimiter =', ' ,$ enclosure ='" ' ,$ escape ='\\' ) {
250
+ public function addCSV ($ name ,$ file ,$ ignoreFirstRows =true ,$ encoding ='UTF-8 ' ,$ delimiter =', ' ,$ enclosure ='" ' ,$ escape ='\\' )
251
+ {
243
252
$ this ->iterator ['csv ' ]++;
244
253
$ srcId = 'CSV # ' .$ this ->iterator ['csv ' ];
245
254
if (!is_string ($ name ) || !preg_match ('/^[a-z0-9]+$/ui ' ,$ name )) {
@@ -283,7 +292,8 @@ public function addCSV($name,$file,$ignoreFirstRows=true,$encoding='UTF-8',$deli
283
292
* @param integer $key
284
293
* @param array $fields
285
294
*/
286
- public function addRegister ($ name , $ csv , $ key , $ fields ) {
295
+ public function addRegister ($ name , $ csv , $ key , $ fields )
296
+ {
287
297
$ fieldIterator = 0 ;
288
298
$ transforms = array ('up ' ,'low ' ,'none ' );
289
299
$ this ->iterator ['register ' ]++;
@@ -330,7 +340,8 @@ public function addRegister($name, $csv, $key, $fields) {
330
340
* @param integer $lastIp
331
341
* @param array $registers
332
342
*/
333
- public function addNetworks ($ csv ,$ ipFormat ,$ firstIp ,$ lastIp ,$ registers ) {
343
+ public function addNetworks ($ csv ,$ ipFormat ,$ firstIp ,$ lastIp ,$ registers )
344
+ {
334
345
$ registersIterator = 0 ;
335
346
$ this ->iterator ['network ' ]++;
336
347
$ netId = 'Network # ' .$ this ->iterator ['network ' ];
@@ -380,7 +391,8 @@ public function addNetworks($csv,$ipFormat,$firstIp,$lastIp,$registers) {
380
391
*
381
392
* @param string $file
382
393
*/
383
- public function create ($ file ) {
394
+ public function create ($ file )
395
+ {
384
396
if (!empty ($ this ->errors )) return null ;
385
397
$ tmpDb = $ this ->temporaryDir . DIRECTORY_SEPARATOR . uniqid ().'tmp.sqlite ' ;
386
398
try {
@@ -454,7 +466,8 @@ public function create($file) {
454
466
/**
455
467
* Create temporary database.
456
468
*/
457
- protected function createTmpDb () {
469
+ protected function createTmpDb ()
470
+ {
458
471
if (empty ($ this ->registers )) return ;
459
472
foreach ($ this ->registers as $ table =>$ register ) {
460
473
$ fields = array ('`_pk` ' , '`_used` ' );
@@ -600,7 +613,8 @@ protected function createTmpDb() {
600
613
*
601
614
* @return array
602
615
*/
603
- protected function createTmpRegisters () {
616
+ protected function createTmpRegisters ()
617
+ {
604
618
if (empty ($ this ->registers )) return array ();
605
619
$ files = array ();
606
620
foreach ($ this ->registers as $ table =>$ register ) {
@@ -673,7 +687,8 @@ protected function createTmpRegisters() {
673
687
*
674
688
* @return string
675
689
*/
676
- protected function createTmpNetworks () {
690
+ protected function createTmpNetworks ()
691
+ {
677
692
$ ip = 0 ;
678
693
$ fields = array ();
679
694
$ values = array ();
@@ -745,7 +760,8 @@ protected function createTmpNetworks() {
745
760
* @param array $array
746
761
* @return string
747
762
*/
748
- public static function packArray ($ format ,$ array ) {
763
+ public static function packArray ($ format ,$ array )
764
+ {
749
765
$ packParams = array_values ($ array );
750
766
array_unshift ($ packParams ,$ format );
751
767
return call_user_func_array ('pack ' ,$ packParams );
@@ -757,7 +773,8 @@ public static function packArray($format,$array) {
757
773
* @param string $prefixOrInetnum
758
774
* @return array
759
775
*/
760
- public static function parseInetnum ($ prefixOrInetnum ) {
776
+ public static function parseInetnum ($ prefixOrInetnum )
777
+ {
761
778
$ result = ['first ' =>null ,'last ' =>null ];
762
779
if (strpos ($ prefixOrInetnum ,'- ' ) !== false ) {
763
780
$ d = explode ('- ' ,$ prefixOrInetnum );
0 commit comments