Passed
Push — master ( d9a29e...796548 )
by Ruben
02:29 queued 24s
created
src/SiteAnalyzer.php 1 patch
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -30,20 +30,17 @@  discard block
 block discarded – undo
30 30
         
31 31
         if(array_key_exists('pdo',$options)){            
32 32
             $pdo = $options['pdo'];	
33
-        }
34
-        else{            
33
+        } else{            
35 34
             $pdo = Persistence::getPDO($config);
36 35
         }
37 36
         
38 37
         try{
39 38
             return Persistence::updateCount($pdo,$config,$options);
40
-        }
41
-        catch(Exception $e) {
39
+        } catch(Exception $e) {
42 40
             try{
43 41
                 Persistence::crateDatabase($pdo, $config);
44 42
                 return Persistence::updateCount($pdo,$config,$options);
45
-            }
46
-            catch(Exception $e) {
43
+            } catch(Exception $e) {
47 44
                 throw new Exception("Site Analyzer could connect to the database.".$e->getMessage());
48 45
             };
49 46
             
@@ -60,12 +57,10 @@  discard block
 block discarded – undo
60 57
         $config = NULL;
61 58
         try{
62 59
             $config = new Configuration("../../../../site-analyzer.ini",$pdoProvided);
63
-        }
64
-        catch(Exception $e){
60
+        } catch(Exception $e){
65 61
             try{
66 62
                 $config = new Configuration("site-analyzer.ini",$pdoProvided); 
67
-            }
68
-            catch(Exception $e){
63
+            } catch(Exception $e){
69 64
                 throw Exception("Config file not found.");
70 65
             }
71 66
         }
@@ -126,8 +121,7 @@  discard block
 block discarded – undo
126 121
         foreach ($data as $row){
127 122
             if(array_key_exists($row['user'],$count)){
128 123
                 $count[$row['user']]++;
129
-            }
130
-            else{
124
+            } else{
131 125
                 $count[$row['user']]=1;
132 126
             }            
133 127
         }
Please login to merge, or discard this patch.
src/Persistence.php 1 patch
Braces   +23 added lines, -46 removed lines patch added patch discarded remove patch
@@ -35,8 +35,7 @@  discard block
 block discarded – undo
35 35
         if($config->getDsn()){
36 36
             try{
37 37
                 return new PDO($config->getDsn(),$config->getUser(),$config->getPassword(),$options);
38
-            }
39
-            catch(Exception $e){                
38
+            } catch(Exception $e){                
40 39
                 if(!$config->getUseOnMemoryDB()){
41 40
                     throw new Exception("Could not create a db connection. Check permissions, configuration, and documentation. ".$e->getMessage());
42 41
                 }
@@ -46,8 +45,7 @@  discard block
 block discarded – undo
46 45
         if($config->getUseOnMemoryDB()){
47 46
             try{
48 47
                 return new PDO("sqlite::memory:",$options);
49
-            }
50
-            catch(Exception $e){
48
+            } catch(Exception $e){
51 49
                 throw new Exception("Could not create a db connection. Check permissions, configuration, and documentation. ".$e->getMessage());                
52 50
             }
53 51
         }
@@ -77,8 +75,7 @@  discard block
 block discarded – undo
77 75
             $stmt->execute();
78 76
             $stmt = $pdo->prepare("CREATE TABLE $db_url_table (id VARCHAR(255), url VARCHAR(255), count INT)");
79 77
             $stmt->execute();
80
-        }
81
-        catch(Exception $e){
78
+        } catch(Exception $e){
82 79
             throw new Exception("Could not create the database. ".$e->getMessage());
83 80
         }        
84 81
         return true;
@@ -119,8 +116,7 @@  discard block
 block discarded – undo
119 116
             $stmt = $pdo->prepare("DROP TABLE $tableName");
120 117
             $stmt->execute();
121 118
            
122
-        }
123
-        catch(Exception $e){
119
+        } catch(Exception $e){
124 120
             throw new Exception("Problem deleting the table $tableName. ".$e->getMessage());
125 121
         }
126 122
         return true;
@@ -140,8 +136,7 @@  discard block
 block discarded – undo
140 136
             $resp = $resp && Persistence::checkOptionsTable($pdo, $config);
141 137
             $resp = $resp && Persistence::checkFromTable($pdo, $config);
142 138
             $resp = $resp && Persistence::checkUrlTable($pdo, $config);
143
-        }
144
-        catch(Exception $e){
139
+        } catch(Exception $e){
145 140
             return false;
146 141
         }        
147 142
         return $resp;
@@ -158,8 +153,7 @@  discard block
 block discarded – undo
158 153
             $stmt = $pdo->prepare("SELECT * FROM $db_from_table WHERE 1==0");
159 154
             $stmt->execute();
160 155
             
161
-        }
162
-        catch(Exception $e){
156
+        } catch(Exception $e){
163 157
             return false;
164 158
         }
165 159
         return true;
@@ -174,8 +168,7 @@  discard block
 block discarded – undo
174 168
             $db_url_table = $config->getUrlTableName();
175 169
             $stmt = $pdo->prepare("SELECT * FROM $db_url_table WHERE 1==0");
176 170
             $stmt->execute();            
177
-        }
178
-        catch(Exception $e){
171
+        } catch(Exception $e){
179 172
             return false;
180 173
         }
181 174
         return true;
@@ -192,8 +185,7 @@  discard block
 block discarded – undo
192 185
             $db_options_table = $config->getOptionsTableName();
193 186
             $stmt = $pdo->prepare("SELECT * FROM $db_options_table WHERE 1==0");
194 187
             $stmt->execute();
195
-        }
196
-        catch(Exception $e){
188
+        } catch(Exception $e){
197 189
             return false;
198 190
         }
199 191
         return true;
@@ -208,8 +200,7 @@  discard block
 block discarded – undo
208 200
             $db_hit_table = $config->getHitTableName();
209 201
             $stmt = $pdo->prepare("SELECT * FROM $db_hit_table WHERE 1==0");
210 202
             $stmt->execute();            
211
-        }
212
-        catch(Exception $e){
203
+        } catch(Exception $e){
213 204
             return false;
214 205
         }
215 206
         return true;        
@@ -234,14 +225,12 @@  discard block
 block discarded – undo
234 225
         
235 226
         if(array_key_exists('url', $options)){
236 227
             $url = $options['url'];
237
-        }
238
-        else if(array_key_exists('HTTP_HOST',$_SERVER)){
228
+        } else if(array_key_exists('HTTP_HOST',$_SERVER)){
239 229
             $url = "http://".$_SERVER['HTTP_HOST'];
240 230
             if(array_key_exists('REQUEST_URI',$_SERVER)){
241 231
                 $url=$url.$_SERVER['REQUEST_URI'];
242 232
             }               
243
-        }
244
-        else{
233
+        } else{
245 234
             $url = "No Info";
246 235
         }
247 236
 
@@ -251,8 +240,7 @@  discard block
 block discarded – undo
251 240
         
252 241
         if(array_key_exists('id', $options)){
253 242
             $id = $options['id'];
254
-        }
255
-        else{
243
+        } else{
256 244
             $id = $url;
257 245
         }
258 246
 
@@ -275,8 +263,7 @@  discard block
 block discarded – undo
275 263
                         
276 264
             if(array_key_exists('from_id', $options)){
277 265
                 $ids = [$options['from_id']];
278
-            }
279
-            else{
266
+            } else{
280 267
                 $from_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'No referer info';
281 268
                 $ids = Persistence::findHitIdsByUrl($pdo,$config,$from_url); 
282 269
                 if(count($ids)==0){
@@ -326,8 +313,7 @@  discard block
 block discarded – undo
326 313
                     $resp[] = $row['id'];
327 314
                 }
328 315
             }
329
-        }
330
-        catch(Exception $e){
316
+        } catch(Exception $e){
331 317
             throw new Exception("Error executing function 'findHitsByUrl'. ".$e->getMessage());
332 318
         }
333 319
         return $resp;
@@ -352,8 +338,7 @@  discard block
 block discarded – undo
352 338
                 }
353 339
             }
354 340
             
355
-        }
356
-        catch(Exception $e){
341
+        } catch(Exception $e){
357 342
             throw new Exception("Error executing function 'getAllHits'. ".$e->getMessage());
358 343
         }
359 344
         return $resp;        
@@ -393,8 +378,7 @@  discard block
 block discarded – undo
393 378
                 }
394 379
             }
395 380
             
396
-        }
397
-        catch(Exception $e){
381
+        } catch(Exception $e){
398 382
             throw new Exception("Error executing function 'getAllUrls'. ".$e->getMessage());
399 383
         }
400 384
         return $resp;
@@ -438,8 +422,7 @@  discard block
 block discarded – undo
438 422
                 }
439 423
             }
440 424
             
441
-        }
442
-        catch(Exception $e){
425
+        } catch(Exception $e){
443 426
             throw new Exception("Error executing function 'getAllUrls'. ".$e->getMessage());
444 427
         }
445 428
         return $resp;
@@ -462,16 +445,13 @@  discard block
 block discarded – undo
462 445
             if(array_key_exists('url',$by) && array_key_exists('id',$by)){
463 446
                 $qdata = [$by['url'], $by['id']];
464 447
                 $tquery = "SELECT f.* FROM  $dbFromtable f,$dbUrltable u WHERE (f.from_id = u.id and f.url = ?) or f.from_id = ?";                
465
-            }
466
-            else if(array_key_exists('url',$by)){
448
+            } else if(array_key_exists('url',$by)){
467 449
                 $qdata = [$by['url']];
468 450
                 $tquery = "SELECT f.* FROM $dbFromtable f,$dbUrltable u where f.from_id = u.id and u.url = ?";
469
-            }
470
-            else if(array_key_exists('id',$by)){
451
+            } else if(array_key_exists('id',$by)){
471 452
                 $qdata = [$by['id']];
472 453
                 $tquery = "SELECT f.* FROM $dbFromtable f where f.from_id = ?";
473
-            }
474
-            else{
454
+            } else{
475 455
                 $qdata = [];
476 456
                 $tquery = "SELECT f.* FROM $dbFromtable f";
477 457
             }
@@ -483,8 +463,7 @@  discard block
 block discarded – undo
483 463
                 }
484 464
             }
485 465
             
486
-        }
487
-        catch(Exception $e){
466
+        } catch(Exception $e){
488 467
             throw new Exception("Error executing function 'findByFrom'. ".$e->getMessage());
489 468
         }
490 469
         return $resp;
@@ -511,8 +490,7 @@  discard block
 block discarded – undo
511 490
                 }
512 491
             }
513 492
             
514
-        }
515
-        catch(Exception $e){
493
+        } catch(Exception $e){
516 494
             throw new Exception("Error reading the database. Method getCounts().".$e->getMessage());
517 495
         }        
518 496
         return $resp;
@@ -536,8 +514,7 @@  discard block
 block discarded – undo
536 514
                 }
537 515
             }
538 516
             
539
-        }
540
-        catch(Exception $e){
517
+        } catch(Exception $e){
541 518
             throw new Exception("Error reading the database. Method getCounts().".$e->getMessage());
542 519
         }
543 520
         return $resp;
Please login to merge, or discard this patch.