Passed
Push — main ( 0f8a49...3d6e36 )
by Sammy
03:07 queued 51s
created
LogLaddy.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -18,20 +18,20 @@  discard block
 block discarded – undo
18 18
 
19 19
 class LogLaddy extends \Psr\Log\AbstractLogger
20 20
 {
21
-    public const REPORTING_USER = 'user_messages';
22
-    public const INTERNAL_ERROR = 'error';
23
-    public const USER_EXCEPTION = 'exception';
24
-    public const LOG_LEVEL_SUCCESS = 'ok';
21
+    public const REPORTING_USER='user_messages';
22
+    public const INTERNAL_ERROR='error';
23
+    public const USER_EXCEPTION='exception';
24
+    public const LOG_LEVEL_SUCCESS='ok';
25 25
 
26
-    private $hasHaltingMessages = false;
26
+    private $hasHaltingMessages=false;
27 27
 
28
-    private $state_agent = null;
29
-    private $debugger = null;
28
+    private $state_agent=null;
29
+    private $debugger=null;
30 30
 
31 31
     public function __construct(StateAgentInterface $agent, Debugger $debug)
32 32
     {
33
-      $this->state_agent = $agent;
34
-      $this->debugger = $debug;
33
+      $this->state_agent=$agent;
34
+      $this->debugger=$debug;
35 35
       $this->setHandlers();
36 36
     }
37 37
 
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
     * handler for errors
52 52
     * use set_error_handler('\HexMakina\kadro\Logger\LogLaddy::error_handler')
53 53
     */
54
-    public function errorHandler($level, $message, $file = '', $line = 0)
54
+    public function errorHandler($level, $message, $file='', $line=0)
55 55
     {
56
-        $loglevel = self::mapErrorLevelToLogLevel($level);
56
+        $loglevel=self::mapErrorLevelToLogLevel($level);
57 57
         $this->$loglevel($message, ['file' => $file, 'line' => $line, 'trace' => debug_backtrace()]);
58 58
     }
59 59
 
@@ -86,22 +86,22 @@  discard block
 block discarded – undo
86 86
 
87 87
   // -- Implementation of LoggerInterface::log(), all other methods are in LoggerTrait
88 88
 
89
-    public function log($level, $message, array $context = [])
89
+    public function log($level, $message, array $context=[])
90 90
     {
91
-        $display_error = null;
91
+        $display_error=null;
92 92
 
93 93
       // --- Handles Throwables (exception_handler())
94 94
         if ($message === self::INTERNAL_ERROR || $message === self::USER_EXCEPTION) {
95
-            $this->hasHaltingMessages = true;
96
-            if (($context = current($context)) !== false) {
97
-                $display_error = Debugger::formatThrowable($context);
98
-                $display_error .= PHP_EOL . Debugger::tracesToString($context->getTrace(), false);
95
+            $this->hasHaltingMessages=true;
96
+            if (($context=current($context)) !== false) {
97
+                $display_error=Debugger::formatThrowable($context);
98
+                $display_error.=PHP_EOL.Debugger::tracesToString($context->getTrace(), false);
99 99
                 error_log($display_error);
100 100
                 self::HTTP500($display_error);
101 101
             }
102 102
         } elseif ($this->systemHalted($level)) { // analyses error level
103
-            $display_error = sprintf(
104
-                PHP_EOL . '%s in file %s:%d' . PHP_EOL . '%s',
103
+            $display_error=sprintf(
104
+                PHP_EOL.'%s in file %s:%d'.PHP_EOL.'%s',
105 105
                 $level,
106 106
                 Debugger::formatFilename($context['file']),
107 107
                 $context['line'],
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
             error_log($display_error);
112 112
 
113
-            $display_error .= PHP_EOL . Debugger::tracesToString($context['trace'], true);
113
+            $display_error.=PHP_EOL.Debugger::tracesToString($context['trace'], true);
114 114
             self::HTTP500($display_error);
115 115
         } else {// --- Handles user messages, through SESSION storage
116 116
             $this->state_agent->addMessage($level, $message, $context);
@@ -147,24 +147,24 @@  discard block
 block discarded – undo
147 147
     private static function mapErrorLevelToLogLevel($level): string
148 148
     {
149 149
       // http://php.net/manual/en/errorfunc.constants.php
150
-        $m = [];
150
+        $m=[];
151 151
 
152
-        $m[E_ERROR] = $m[E_PARSE] = $m[E_CORE_ERROR] = $m[E_COMPILE_ERROR] = $m[E_USER_ERROR] = $m[E_RECOVERABLE_ERROR] = LogLevel::ALERT;
153
-        $m[1] = $m[4] = $m[16] = $m[64] = $m[256] = $m[4096] = LogLevel::ALERT;
152
+        $m[E_ERROR]=$m[E_PARSE]=$m[E_CORE_ERROR]=$m[E_COMPILE_ERROR]=$m[E_USER_ERROR]=$m[E_RECOVERABLE_ERROR]=LogLevel::ALERT;
153
+        $m[1]=$m[4]=$m[16]=$m[64]=$m[256]=$m[4096]=LogLevel::ALERT;
154 154
 
155
-        $m[E_WARNING] = $m[E_CORE_WARNING] = $m[E_COMPILE_WARNING] = $m[E_USER_WARNING] = LogLevel::CRITICAL;
156
-        $m[2] = $m[32] = $m[128] = $m[512] = LogLevel::CRITICAL;
155
+        $m[E_WARNING]=$m[E_CORE_WARNING]=$m[E_COMPILE_WARNING]=$m[E_USER_WARNING]=LogLevel::CRITICAL;
156
+        $m[2]=$m[32]=$m[128]=$m[512]=LogLevel::CRITICAL;
157 157
 
158
-        $m[E_NOTICE] = $m[E_USER_NOTICE] = LogLevel::ERROR;
159
-        $m[8] = $m[1024] = LogLevel::ERROR;
158
+        $m[E_NOTICE]=$m[E_USER_NOTICE]=LogLevel::ERROR;
159
+        $m[8]=$m[1024]=LogLevel::ERROR;
160 160
 
161
-        $m[E_STRICT] = $m[E_DEPRECATED] = $m[E_USER_DEPRECATED] = $m[E_ALL] = LogLevel::DEBUG;
162
-        $m[2048] = $m[8192] = $m[16384] = $m[32767] = LogLevel::DEBUG;
161
+        $m[E_STRICT]=$m[E_DEPRECATED]=$m[E_USER_DEPRECATED]=$m[E_ALL]=LogLevel::DEBUG;
162
+        $m[2048]=$m[8192]=$m[16384]=$m[32767]=LogLevel::DEBUG;
163 163
 
164 164
         if (isset($m[$level])) {
165 165
             return $m[$level];
166 166
         }
167 167
 
168
-        throw new \Exception(__FUNCTION__ . "($level): $level is unknown");
168
+        throw new \Exception(__FUNCTION__."($level): $level is unknown");
169 169
     }
170 170
 }
Please login to merge, or discard this patch.