1313class DatabaseCommand
1414{
1515 public const TABLE_SUM = 'statistics_sums ' ;
16+
1617 private const DEBUG_PREFIX = 'proxystatistics:DatabaseCommand - ' ;
1718
1819 private const TABLE_PER_USER = 'statistics_per_user ' ;
@@ -87,7 +88,7 @@ public function insertLogin($request, &$date)
8788 $ ids [$ tableId ] = $ this ->getEntityDbIdFromEntityIdentifier ($ table , $ entities [$ side ], $ tableId );
8889 }
8990
90- if (false === $ this ->writeLogin ($ date , $ ids , $ userId )) {
91+ if ($ this ->writeLogin ($ date , $ ids , $ userId ) === false ) {
9192 Logger::error (self ::DEBUG_PREFIX . 'login record has not been inserted (data \'' . json_encode ([
9293 'user ' => $ userId ,
9394 'ids ' => $ ids ,
@@ -171,7 +172,7 @@ public function aggregate()
171172 'day '
172173 ) . '), EXTRACT(DAY FROM ' . $ this ->escape_col ('day ' ) . '), ' ;
173174 foreach ($ ids as $ id ) {
174- $ query .= (null === $ id ? '0 ' : $ id ) . ', ' ;
175+ $ query .= ($ id === null ? '0 ' : $ id ) . ', ' ;
175176 }
176177 $ query .= 'SUM(logins), COUNT(DISTINCT ' . $ this ->escape_col ('user ' ) . ') '
177178 . 'FROM ' . $ this ->tables [self ::TABLE_PER_USER ] . ' '
@@ -221,7 +222,7 @@ public function aggregate()
221222 $ written = $ this ->conn ->write ($ query , $ params );
222223 if (is_bool ($ written ) && !$ written ) {
223224 Logger::warning (self ::DEBUG_PREFIX . $ msg . ' failed ' );
224- } elseif (0 === $ written ) {
225+ } elseif ($ written === 0 ) {
225226 Logger::warning (self ::DEBUG_PREFIX . $ msg . ' completed, but updated 0 rows. ' );
226227 } else {
227228 Logger::info (self ::DEBUG_PREFIX . $ msg . ' completed and updated ' . $ written . ' rows. ' );
@@ -272,7 +273,7 @@ private function writeLogin($date, $ids, $user): bool
272273
273274 return false ;
274275 }
275- if (0 === $ written ) {
276+ if ($ written === 0 ) {
276277 Logger::debug (self ::DEBUG_PREFIX . 'login entry has been inserted, but has updated 0 rows. ' );
277278
278279 return false ;
@@ -287,23 +288,23 @@ private function prepareEntitiesData($request): array
287288 Config::MODE_IDP => [],
288289 Config::MODE_SP => [],
289290 ];
290- if (Config:: MODE_IDP !== $ this ->mode && Config::MODE_MULTI_IDP !== $ this ->mode ) {
291+ if ($ this ->mode !== Config::MODE_IDP && $ this ->mode !== Config:: MODE_MULTI_IDP ) {
291292 $ entities [Config::MODE_IDP ][self ::KEY_ID ] = $ this ->getIdpIdentifier ($ request );
292293 $ entities [Config::MODE_IDP ][self ::KEY_NAME ] = $ this ->getIdpName ($ request );
293294 }
294- if (Config:: MODE_SP !== $ this ->mode ) {
295+ if ($ this ->mode !== Config:: MODE_SP ) {
295296 $ entities [Config::MODE_SP ][self ::KEY_ID ] = $ this ->getSpIdentifier ($ request );
296297 $ entities [Config::MODE_SP ][self ::KEY_NAME ] = $ this ->getSpName ($ request );
297298 }
298299
299- if (Config:: MODE_PROXY !== $ this ->mode && Config::MODE_MULTI_IDP !== $ this ->mode ) {
300+ if ($ this ->mode !== Config::MODE_PROXY && $ this ->mode !== Config:: MODE_MULTI_IDP ) {
300301 $ entities [$ this ->mode ] = $ this ->config ->getSideInfo ($ this ->mode );
301302 if (empty ($ entities [$ this ->mode ][self ::KEY_ID ]) || empty ($ entities [$ this ->mode ][self ::KEY_NAME ])) {
302303 Logger::error (self ::DEBUG_PREFIX . 'Invalid configuration (id, name) for ' . $ this ->mode );
303304 }
304305 }
305306
306- if (Config:: MODE_MULTI_IDP === $ this ->mode ) {
307+ if ($ this ->mode === Config:: MODE_MULTI_IDP ) {
307308 $ entities [Config::MODE_IDP ] = $ this ->config ->getSideInfo (Config::MODE_IDP );
308309 if (empty ($ entities [Config::MODE_IDP ][self ::KEY_ID ]) || empty ($ entities [Config::MODE_IDP ][self ::KEY_NAME ])) {
309310 Logger::error (self ::DEBUG_PREFIX . 'Invalid configuration (id, name) for ' . $ this ->mode );
@@ -346,7 +347,7 @@ private function addWhereId($where, &$query, &$params)
346347 $ table = self ::TABLE_SIDES [$ side ];
347348 $ column = self ::TABLE_IDS [$ table ];
348349 $ part = $ column ;
349- if (null === $ value ) {
350+ if ($ value === null ) {
350351 $ part .= '=0 ' ;
351352 } else {
352353 $ part .= '=:id ' ;
@@ -363,8 +364,8 @@ private function addWhereId($where, &$query, &$params)
363364
364365 private function addDaysRange ($ days , &$ query , &$ params , $ not = false )
365366 {
366- if (0 !== $ days ) { // 0 = all time
367- if (false === stripos ($ query , 'WHERE ' )) {
367+ if ($ days !== 0 ) { // 0 = all time
368+ if (stripos ($ query , 'WHERE ' ) === false ) {
368369 $ query .= 'WHERE ' ;
369370 } else {
370371 $ query .= 'AND ' ;
@@ -408,7 +409,7 @@ private function getAggregateGroupBy($ids): string
408409 {
409410 $ columns = ['day ' ];
410411 foreach ($ ids as $ id ) {
411- if (null !== $ id ) {
412+ if ($ id !== null ) {
412413 $ columns [] = $ id ;
413414 }
414415 }
@@ -460,12 +461,12 @@ private function read($query, $params): PDOStatement
460461
461462 private function isPgsql (): bool
462463 {
463- return ' pgsql ' === $ this ->conn ->getDriver ();
464+ return $ this ->conn ->getDriver () === ' pgsql ' ;
464465 }
465466
466467 private function isMysql (): bool
467468 {
468- return ' mysql ' === $ this ->conn ->getDriver ();
469+ return $ this ->conn ->getDriver () === ' mysql ' ;
469470 }
470471
471472 private function unknownDriver ()
0 commit comments