]> git.mxchange.org Git - friendica.git/commitdiff
improving code
authorPhilipp Holzer <admin@philipp.info>
Mon, 28 Jan 2019 17:26:35 +0000 (18:26 +0100)
committerPhilipp Holzer <admin@philipp.info>
Mon, 28 Jan 2019 17:26:35 +0000 (18:26 +0100)
src/Util/Logger/FriendicaProcessor.php

index 627f628b881d05c4a5372bac61aeb68943b9b30c..9f52a6f1261e185cefd99c53ec95ffb9777b1bf0 100644 (file)
@@ -48,19 +48,7 @@ class FriendicaProcessor implements ProcessorInterface
                $i = 1;
 
                while ($this->isTraceClassOrSkippedFunction($trace, $i)) {
-                       if (isset($trace[$i]['class'])) {
-                               foreach ($this->skipClassesPartials as $part) {
-                                       if (strpos($trace[$i]['class'], $part) !== false) {
-                                               $i++;
-                                               continue 2;
-                                       }
-                               }
-                       } elseif (in_array($trace[$i]['function'], $this->skipFunctions)) {
-                               $i++;
-                               continue;
-                       }
-
-                       break;
+                       $i++;
                }
 
                $i += $this->skipStackFramesCount;
@@ -78,12 +66,29 @@ class FriendicaProcessor implements ProcessorInterface
                return $record;
        }
 
+       /**
+        * Checks if the current trace class or function has to be skipped
+        *
+        * @param array $trace The current trace array
+        * @param int   $index The index of the current hierarchy level
+        * @return bool True if the class or function should get skipped, otherwise false
+        */
        private function isTraceClassOrSkippedFunction(array $trace, $index)
        {
                if (!isset($trace[$index])) {
                        return false;
                }
 
-               return isset($trace[$index]['class']) || in_array($trace[$index]['function'], $this->skipFunctions);
+               if (isset($trace[$index]['class'])) {
+                       foreach ($this->skipClassesPartials as $part) {
+                               if (strpos($trace[$index]['class'], $part) !== false) {
+                                       return true;
+                               }
+                       }
+               } elseif (in_array($trace[$index]['function'], $this->skipFunctions)) {
+                       return true;
+               }
+
+               return false;
        }
 }