Passed
Push — master ( 4f923e...f2cf92 )
by 世昌
01:48
created
nebula/component/debug/attach/AttachTrait.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
      *
12 12
      * @var array
13 13
      */
14
-    protected $attribute=[];
14
+    protected $attribute = [];
15 15
     
16 16
     public function mergeAttribute(array $value)
17 17
     {
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
     protected function analyse(array $context)
22 22
     {
23 23
         $replace = [];
24
-        $attach  =[] ;
24
+        $attach  = [];
25 25
         foreach ($context as $key => $val) {
26
-            if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString')) && ! $val instanceof \Exception) {
27
-                $replace['{' . $key . '}'] = $val;
26
+            if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString')) && !$val instanceof \Exception) {
27
+                $replace['{'.$key.'}'] = $val;
28 28
             } else {
29 29
                 $attach[$key] = $val;
30 30
             }
@@ -34,18 +34,18 @@  discard block
 block discarded – undo
34 34
 
35 35
     public function interpolate(string $message, array $context, array $attribute)
36 36
     {
37
-        list($attach, $replace) =  $this->analyse($context);
37
+        list($attach, $replace) = $this->analyse($context);
38 38
         $attribute = array_merge($this->attribute, $attribute);
39 39
         foreach ($attribute as $key => $val) {
40
-            $replace['%' . $key . '%'] = $val;
40
+            $replace['%'.$key.'%'] = $val;
41 41
         }
42 42
         $message = strtr($message, $replace).PHP_EOL;
43 43
         foreach ($attach as $name => $value) {
44
-            $message.= $name.' = ';
44
+            $message .= $name.' = ';
45 45
             if ($value instanceof AttachValueInterface) {
46
-                $message.= $value->getLogAttach().PHP_EOL;
46
+                $message .= $value->getLogAttach().PHP_EOL;
47 47
             } else {
48
-                $message.= DumpTrait::parameterToString($value).PHP_EOL;
48
+                $message .= DumpTrait::parameterToString($value).PHP_EOL;
49 49
             }
50 50
         }
51 51
         return $message;
Please login to merge, or discard this patch.
nebula/component/debug/Debug.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 
16 16
 class Debug implements LoggerInterface, LoggerAwareInterface, DumpInterface, AttachInterface, ConfigInterface
17 17
 {
18
-    use LoggerTrait,LoggerAwareTrait,DumpTrait,AttachTrait,ConfigTrait;
18
+    use LoggerTrait, LoggerAwareTrait, DumpTrait, AttachTrait, ConfigTrait;
19 19
 
20 20
     
21 21
 
Please login to merge, or discard this patch.
nebula/component/debug/Caller.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@
 block discarded – undo
9 9
     protected $ignorePath = [__FILE__];
10 10
     protected $backtrace;
11 11
 
12
-    public function __construct(array $backtrace, array $ignorePath =[])
12
+    public function __construct(array $backtrace, array $ignorePath = [])
13 13
     {
14 14
         $this->ignorePath = \array_merge($this->ignorePath, $ignorePath);
15 15
         $this->backtrace = $backtrace;
16 16
     }
17 17
 
18
-    public function getCallerTrace():?array
18
+    public function getCallerTrace(): ?array
19 19
     {
20 20
         foreach ($this->backtrace as $trace) {
21 21
             if (array_key_exists('file', $trace)) {
Please login to merge, or discard this patch.
nebula/component/debug/log/logger/FileLogger.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -46,17 +46,17 @@  discard block
 block discarded – undo
46 46
      * @throws FileLoggerException
47 47
      * @param array $config
48 48
      */
49
-    public function __construct(array $config=[])
49
+    public function __construct(array $config = [])
50 50
     {
51 51
         $this->applyConfig($config);
52 52
         $temp = tmpfile();
53 53
         if ($temp === false) {
54
-            $this->tempname = $this->config['save-path'].'/log-'. microtime(true).'.tmp';
54
+            $this->tempname = $this->config['save-path'].'/log-'.microtime(true).'.tmp';
55 55
             $temp = fopen($this->tempname, 'w+');
56 56
         }
57 57
         if ($temp !== false) {
58 58
             $this->temp = $temp;
59
-        }else{
59
+        } else {
60 60
             throw new FileLoggerException(__CLASS__.':'.sprintf('cannot create log file'));
61 61
         }
62 62
         $this->latest = $this->config['save-path'].'/'.$this->config['file-name'];
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
     
77 77
     protected function packLogFile()
78 78
     {
79
-        $logFile= $this->latest;
80
-        $path=preg_replace('/[\\\\]+/', '/', $this->config['save-zip-path'] .'/'.date('Y-m-d').'.zip');
79
+        $logFile = $this->latest;
80
+        $path = preg_replace('/[\\\\]+/', '/', $this->config['save-zip-path'].'/'.date('Y-m-d').'.zip');
81 81
         $zip = new ZipArchive;
82 82
         $res = $zip->open($path, ZipArchive::CREATE);
83 83
         if ($res === true) {
84
-            if ($zip->addFile($logFile, date('Y-m-d'). '-'. $zip->numFiles .'.log')) {
84
+            if ($zip->addFile($logFile, date('Y-m-d').'-'.$zip->numFiles.'.log')) {
85 85
                 array_push($this->removeFiles, $logFile);
86 86
             }
87 87
             $it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->config['save-pack-path']));
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             $zip->close();
94 94
         } else {
95 95
             if (is_file($logFile) && file_exists($logFile)) {
96
-                rename($logFile, $this->config['save-path'] . '/' . date('Y-m-d'). '-'. substr(md5_file($logFile), 0, 8).'.log');
96
+                rename($logFile, $this->config['save-path'].'/'.date('Y-m-d').'-'.substr(md5_file($logFile), 0, 8).'.log');
97 97
             }
98 98
         }
99 99
     }
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      */
106 106
     protected function checkSize():bool
107 107
     {
108
-        $logFile= $this->latest;
108
+        $logFile = $this->latest;
109 109
         if (file_exists($logFile)) {
110 110
             if (filesize($logFile) > $this->config['max-file-size']) {
111 111
                 return true;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
     public function log($level, string $message, array $context = [])
119 119
     {
120
-        if (LogLevel::compare($level, $this->config['log-level']) >=0) {
120
+        if (LogLevel::compare($level, $this->config['log-level']) >= 0) {
121 121
             $replace = [];
122 122
             $message = $this->interpolate($message, $context);
123 123
             $replace['%level%'] = $level;
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     {
133 133
         $replace = [];
134 134
         foreach ($context as $key => $val) {
135
-            $replace['{' . $key . '}'] = $val;
135
+            $replace['{'.$key.'}'] = $val;
136 136
         }
137 137
         return strtr($message, $replace);
138 138
     }
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
     protected function rollLatest()
141 141
     {
142 142
         if (isset($this->latest)) {
143
-            $size=ftell($this->temp);
143
+            $size = ftell($this->temp);
144 144
             fseek($this->temp, 0);
145 145
             if ($size > 0) {
146
-                $body=fread($this->temp, $size);
146
+                $body = fread($this->temp, $size);
147 147
                 file_put_contents($this->latest, $body, FILE_APPEND);
148 148
             }
149 149
             fclose($this->temp);
Please login to merge, or discard this patch.
nebula/component/debug/ConfigInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace nebula\component\debug;
3 3
 
4
-interface ConfigInterface  {
4
+interface ConfigInterface {
5 5
     public function applyConfig(array $config);
6 6
 }
Please login to merge, or discard this patch.
nebula/component/debug/ConfigTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
             $this->config[$name] = $config[$name] ?? $this->config[$name] ?? $value;
19 19
         }
20 20
     }
21
-    public function getConfig(string $name, $default =null) {
21
+    public function getConfig(string $name, $default = null) {
22 22
         $defaultConfig = $this->getDefaultConfig();
23 23
         return $this->config[$name] ?? $defaultConfig[$name] ?? $default;
24 24
     }
Please login to merge, or discard this patch.