Passed
Push — main ( f1e509...424d19 )
by Sammy
11:23 queued 09:49
created
LogLaddy.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -153,7 +153,7 @@
 block discarded – undo
153 153
    * const NOTICE    = 'notice'; // Normal but significant events.
154 154
    * const INFO      = 'info'; // Interesting events. User logs in, SQL logs.
155 155
    * const DEBUG     = 'debug'; // Detailed debug information.
156
-  */
156
+   */
157 157
     private static function map_error_level_to_log_level($level): string
158 158
     {
159 159
       // http://php.net/manual/en/errorfunc.constants.php
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
 
15 15
 class LogLaddy implements LoggerInterface
16 16
 {
17
-    use \Psr\Log\LoggerTrait;           // PSR implementation
18
-    use \HexMakina\Debugger\Debugger;   // Debugger
17
+    use \Psr\Log\LoggerTrait; // PSR implementation
18
+    use \HexMakina\Debugger\Debugger; // Debugger
19 19
 
20
-    const REPORTING_USER = 'user_messages';
21
-    const INTERNAL_ERROR = 'error';
22
-    const USER_EXCEPTION = 'exception';
23
-    const LOG_LEVEL_SUCCESS = 'ok';
20
+    const REPORTING_USER='user_messages';
21
+    const INTERNAL_ERROR='error';
22
+    const USER_EXCEPTION='exception';
23
+    const LOG_LEVEL_SUCCESS='ok';
24 24
 
25
-    private $has_halting_messages = false;
25
+    private $has_halting_messages=false;
26 26
 
27 27
   /**
28 28
    * Everything went fine, which is always nice.
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
    * @return void
34 34
    */
35 35
 
36
-    public function nice($message, array $context = array())
36
+    public function nice($message, array $context=array())
37 37
     {
38 38
         $this->log(LogLevel::NICE, $message, $context);
39 39
     }
40 40
 
41 41
   // -- Static handlers for error, use set_error_handler('\HexMakina\kadro\Logger\LogLaddy::error_handler')
42
-    public static function error_handler($level, $message, $file = '', $line = 0)
42
+    public static function error_handler($level, $message, $file='', $line=0)
43 43
     {
44
-        $loglevel = self::map_error_level_to_log_level($level);
44
+        $loglevel=self::map_error_level_to_log_level($level);
45 45
 
46 46
         (new LogLaddy())->$loglevel($message, ['file' => $file, 'line' => $line, 'trace' => debug_backtrace()]);
47 47
     }
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
   // -- Static handlers for throwables, use set_exception_handler('\HexMakina\kadro\Logger\LogLaddy::exception_handler');
50 50
     public static function exception_handler(\Throwable $throwable)
51 51
     {
52
-        $context = [];
53
-        $context['text'] = $throwable->getMessage();
54
-        $context['file'] = $throwable->getFile();
55
-        $context['line'] = $throwable->getLine();
56
-        $context['code'] = $throwable->getCode();
57
-        $context['class'] = get_class($throwable);
58
-        $context['trace'] = $throwable->getTrace();
59
-
60
-        $lad = new LogLaddy();
52
+        $context=[];
53
+        $context['text']=$throwable->getMessage();
54
+        $context['file']=$throwable->getFile();
55
+        $context['line']=$throwable->getLine();
56
+        $context['code']=$throwable->getCode();
57
+        $context['class']=get_class($throwable);
58
+        $context['trace']=$throwable->getTrace();
59
+
60
+        $lad=new LogLaddy();
61 61
         if (is_subclass_of($throwable, 'Error') || get_class($throwable) === 'Error') {
62 62
             $lad->alert(self::INTERNAL_ERROR, $context);
63 63
         } elseif (is_subclass_of($throwable, 'Exception') || get_class($throwable) === 'Exception') {
@@ -81,21 +81,21 @@  discard block
 block discarded – undo
81 81
 
82 82
   // -- Implementation of LoggerInterface::log(), all other methods are in LoggerTrait
83 83
 
84
-    public function log($level, $message, array $context = [])
84
+    public function log($level, $message, array $context=[])
85 85
     {
86
-        $display_error = null;
86
+        $display_error=null;
87 87
 
88 88
       // --- Handles Throwables (exception_handler())
89 89
         if ($message == self::INTERNAL_ERROR || $message == self::USER_EXCEPTION) {
90
-            $this->has_halting_messages = true;
91
-            $display_error = self::format_throwable_message($context['class'], $context['code'], $context['file'], $context['line'], $context['text']);
90
+            $this->has_halting_messages=true;
91
+            $display_error=self::format_throwable_message($context['class'], $context['code'], $context['file'], $context['line'], $context['text']);
92 92
             error_log($display_error);
93
-            $display_error .= self::format_trace($context['trace'], false);
93
+            $display_error.=self::format_trace($context['trace'], false);
94 94
             self::HTTP_500($display_error);
95 95
         } elseif ($this->system_halted($level)) { // analyses error level
96
-            $display_error = sprintf(PHP_EOL . '%s in file %s:%d' . PHP_EOL . '%s', $level, self::format_file($context['file']), $context['line'], $message);
96
+            $display_error=sprintf(PHP_EOL.'%s in file %s:%d'.PHP_EOL.'%s', $level, self::format_file($context['file']), $context['line'], $message);
97 97
             error_log($display_error);
98
-            $display_error .= self::format_trace($context['trace'], true);
98
+            $display_error.=self::format_trace($context['trace'], true);
99 99
             self::HTTP_500($display_error);
100 100
         } else {// --- Handles user messages, through SESSION storage
101 101
             $this->report_to_user($level, $message, $context);
@@ -118,17 +118,17 @@  discard block
 block discarded – undo
118 118
   // -- User messages
119 119
 
120 120
   // -- User messages:add one
121
-    public function report_to_user($level, $message, $context = [])
121
+    public function report_to_user($level, $message, $context=[])
122 122
     {
123 123
         if (!isset($_SESSION[self::REPORTING_USER])) {
124
-            $_SESSION[self::REPORTING_USER] = [];
124
+            $_SESSION[self::REPORTING_USER]=[];
125 125
         }
126 126
 
127 127
         if (!isset($_SESSION[self::REPORTING_USER][$level])) {
128
-            $_SESSION[self::REPORTING_USER][$level] = [];
128
+            $_SESSION[self::REPORTING_USER][$level]=[];
129 129
         }
130 130
 
131
-        $_SESSION[self::REPORTING_USER][$level][] = [$message, $context];
131
+        $_SESSION[self::REPORTING_USER][$level][]=[$message, $context];
132 132
     }
133 133
 
134 134
   // -- User messages:get all
@@ -157,24 +157,24 @@  discard block
 block discarded – undo
157 157
     private static function map_error_level_to_log_level($level): string
158 158
     {
159 159
       // http://php.net/manual/en/errorfunc.constants.php
160
-        $m = [];
160
+        $m=[];
161 161
 
162
-        $m[E_ERROR] = $m[E_PARSE] = $m[E_CORE_ERROR] = $m[E_COMPILE_ERROR] = $m[E_USER_ERROR] = $m[E_RECOVERABLE_ERROR] = LogLevel::ALERT;
163
-        $m[1] = $m[4] = $m[16] = $m[64] = $m[256] = $m[4096] = LogLevel::ALERT;
162
+        $m[E_ERROR]=$m[E_PARSE]=$m[E_CORE_ERROR]=$m[E_COMPILE_ERROR]=$m[E_USER_ERROR]=$m[E_RECOVERABLE_ERROR]=LogLevel::ALERT;
163
+        $m[1]=$m[4]=$m[16]=$m[64]=$m[256]=$m[4096]=LogLevel::ALERT;
164 164
 
165
-        $m[E_WARNING] = $m[E_CORE_WARNING] = $m[E_COMPILE_WARNING] = $m[E_USER_WARNING] = LogLevel::CRITICAL;
166
-        $m[2] = $m[32] = $m[128] = $m[512] = LogLevel::CRITICAL;
165
+        $m[E_WARNING]=$m[E_CORE_WARNING]=$m[E_COMPILE_WARNING]=$m[E_USER_WARNING]=LogLevel::CRITICAL;
166
+        $m[2]=$m[32]=$m[128]=$m[512]=LogLevel::CRITICAL;
167 167
 
168
-        $m[E_NOTICE] = $m[E_USER_NOTICE] = LogLevel::ERROR;
169
-        $m[8] = $m[1024] = LogLevel::ERROR;
168
+        $m[E_NOTICE]=$m[E_USER_NOTICE]=LogLevel::ERROR;
169
+        $m[8]=$m[1024]=LogLevel::ERROR;
170 170
 
171
-        $m[E_STRICT] = $m[E_DEPRECATED] = $m[E_USER_DEPRECATED] = $m[E_ALL] = LogLevel::DEBUG;
172
-        $m[2048] = $m[8192] = $m[16384] = $m[32767] = LogLevel::DEBUG;
171
+        $m[E_STRICT]=$m[E_DEPRECATED]=$m[E_USER_DEPRECATED]=$m[E_ALL]=LogLevel::DEBUG;
172
+        $m[2048]=$m[8192]=$m[16384]=$m[32767]=LogLevel::DEBUG;
173 173
 
174 174
         if (isset($m[$level])) {
175 175
             return $m[$level];
176 176
         }
177 177
 
178
-        throw new \Exception(__FUNCTION__ . "($level): $level is unknown");
178
+        throw new \Exception(__FUNCTION__."($level): $level is unknown");
179 179
     }
180 180
 }
Please login to merge, or discard this patch.
LoggerInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@
 block discarded – undo
15 15
    *
16 16
    * @return void
17 17
    */
18
-    public function nice($message, array $context = array());
18
+    public function nice($message, array $context=array());
19 19
 
20
-    public function report_to_user($level, $message, $context = []);
20
+    public function report_to_user($level, $message, $context=[]);
21 21
     public function get_user_report();
22 22
     public function clean_user_report();
23 23
 
Please login to merge, or discard this patch.