Passed
Push — master ( 3354b2...c3d752 )
by 世昌
01:43
created
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
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
     }
21 21
     public function getConfig(string $name) {
22 22
         $defaultConfig = $this->getDefaultConfig();
23
-        return $this->config[$name] ?? $defaultConfig[$name];;
23
+        return $this->config[$name] ?? $defaultConfig[$name]; ;
24 24
     }
25 25
 
26 26
     abstract public function getDefaultConfig():array;
Please login to merge, or discard this patch.
nebula/component/debug/log/logger/ConsoleLogger.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@
 block discarded – undo
10 10
 {
11 11
     public function log($level, string $message, array $context = [])
12 12
     {
13
-        print date('Y-m-d H:i:s') .' ' . $this->interpolate($message, $context) . PHP_EOL;
13
+        print date('Y-m-d H:i:s').' '.$this->interpolate($message, $context).PHP_EOL;
14 14
     }
15 15
     public function interpolate(string $message, array $context)
16 16
     {
17 17
         $replace = [];
18 18
         foreach ($context as $key => $val) {
19
-            $replace['{' . $key . '}'] = $val;
19
+            $replace['{'.$key.'}'] = $val;
20 20
         }
21 21
         return strtr($message, $replace);
22 22
     }
Please login to merge, or discard this patch.
public/dev.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 use nebula\component\request\Request;
7 7
 use nebula\component\debug\log\logger\FileLogger;
8 8
 
9
-require_once __DIR__ .'/../vendor/autoload.php';
9
+require_once __DIR__.'/../vendor/autoload.php';
10 10
 
11 11
 $logger = new FileLogger(
12 12
     [
@@ -30,19 +30,19 @@  discard block
 block discarded – undo
30 30
 $debug->timeEnd('Request::buildFromServer');
31 31
 
32 32
 $debug->debug('request apply true', [
33
-    'request' => $request ,
33
+    'request' => $request,
34 34
     'exception' => new Exception('test exception')
35 35
 ]);
36 36
 
37 37
 $debug->debug('request  getBasicURI {url}', ['url' => $request->getBasicURI()]);
38 38
 
39
-function formatBytes(int $bytes, int $precision=0)
39
+function formatBytes(int $bytes, int $precision = 0)
40 40
 {
41
-    $human= ['B', 'KB', 'MB', 'GB', 'TB'];
41
+    $human = ['B', 'KB', 'MB', 'GB', 'TB'];
42 42
     $bytes = max($bytes, 0);
43
-    $pow = floor(($bytes?log($bytes):0)/log(1024));
44
-    $pos = min($pow, count($human)-1);
45
-    $bytes /= (1 << (10* $pos));
43
+    $pow = floor(($bytes ?log($bytes) : 0) / log(1024));
44
+    $pos = min($pow, count($human) - 1);
45
+    $bytes /= (1 << (10 * $pos));
46 46
     return round($bytes, $precision).' '.$human[$pos];
47 47
 }
48 48
 
Please login to merge, or discard this patch.
nebula/component/debug/attach/AttachTrait.php 1 patch
Spacing   +8 added lines, -8 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 addAttribute(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,19 +34,19 @@  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);
43 43
         $attachInfo = '';
44 44
         foreach ($attach as $name => $value) {
45 45
             $attachInfo = $name.' = ';
46 46
             if ($value instanceof AttachValueInterface) {
47
-                $attachInfo.= $value->getLogAttach().PHP_EOL;
47
+                $attachInfo .= $value->getLogAttach().PHP_EOL;
48 48
             } else {
49
-                $attachInfo.= DumpTrait::parameterToString($value).PHP_EOL;
49
+                $attachInfo .= DumpTrait::parameterToString($value).PHP_EOL;
50 50
             }
51 51
         }
52 52
         if (strlen($attachInfo) > 0) {
Please login to merge, or discard this patch.
nebula/component/debug/Debug.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 class Debug implements LoggerInterface, LoggerAwareInterface, DumpInterface, AttachInterface, ConfigInterface
18 18
 {
19
-    use LoggerTrait,LoggerAwareTrait,DumpTrait,AttachTrait,ConfigTrait;
19
+    use LoggerTrait, LoggerAwareTrait, DumpTrait, AttachTrait, ConfigTrait;
20 20
 
21 21
     /**
22 22
      * 时间记录
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     {
52 52
         $replace = [];
53 53
         foreach ($context as $key => $val) {
54
-            $replace['{' . $key . '}'] = $val;
54
+            $replace['{'.$key.'}'] = $val;
55 55
         }
56 56
         return strtr($message, $replace);
57 57
     }
@@ -67,26 +67,26 @@  discard block
 block discarded – undo
67 67
         return $attribute;
68 68
     }
69 69
 
70
-    protected static function formatBytes(int $bytes, int $precision=0)
70
+    protected static function formatBytes(int $bytes, int $precision = 0)
71 71
     {
72
-        $human= ['B', 'KB', 'MB', 'GB', 'TB'];
72
+        $human = ['B', 'KB', 'MB', 'GB', 'TB'];
73 73
         $bytes = max($bytes, 0);
74
-        $pow = floor(($bytes?log($bytes):0)/log(1024));
75
-        $pos = min($pow, count($human)-1);
76
-        $bytes /= (1 << (10* $pos));
74
+        $pow = floor(($bytes ?log($bytes) : 0) / log(1024));
75
+        $pos = min($pow, count($human) - 1);
76
+        $bytes /= (1 << (10 * $pos));
77 77
         return round($bytes, $precision).' '.$human[$pos];
78 78
     }
79 79
 
80
-    public function time(string $name, string $type= LogLevel::INFO)
80
+    public function time(string $name, string $type = LogLevel::INFO)
81 81
     {
82
-        $this->timeRecord[$name]=['time'=>microtime(true),'level'=>$type];
82
+        $this->timeRecord[$name] = ['time'=>microtime(true), 'level'=>$type];
83 83
     }
84 84
 
85 85
     public function timeEnd(string $name)
86 86
     {
87 87
         if (\array_key_exists($name, $this->timeRecord)) {
88
-            $pass=microtime(true)-$this->timeRecord[$name]['time'];
89
-            $this->log($this->timeRecord[$name]['level'], 'process cost '. $name.' '. number_format($pass, 5).'s');
88
+            $pass = microtime(true) - $this->timeRecord[$name]['time'];
89
+            $this->log($this->timeRecord[$name]['level'], 'process cost '.$name.' '.number_format($pass, 5).'s');
90 90
             return $pass;
91 91
         }
92 92
         return 0;
Please login to merge, or discard this patch.
nebula/component/debug/log/logger/FileLogger.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -46,12 +46,12 @@  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->getConfig('save-path').'/log-'. microtime(true).'.tmp';
54
+            $this->tempname = $this->getConfig('save-path').'/log-'.microtime(true).'.tmp';
55 55
             $temp = fopen($this->tempname, 'w+');
56 56
         }
57 57
         if ($temp !== false) {
@@ -77,12 +77,12 @@  discard block
 block discarded – undo
77 77
     
78 78
     protected function packLogFile()
79 79
     {
80
-        $logFile= $this->latest;
81
-        $path=preg_replace('/[\\\\]+/', '/', $this->getConfig('save-zip-path') .'/'.date('Y-m-d').'.zip');
80
+        $logFile = $this->latest;
81
+        $path = preg_replace('/[\\\\]+/', '/', $this->getConfig('save-zip-path').'/'.date('Y-m-d').'.zip');
82 82
         $zip = new ZipArchive;
83 83
         $res = $zip->open($path, ZipArchive::CREATE);
84 84
         if ($res === true) {
85
-            if ($zip->addFile($logFile, date('Y-m-d'). '-'. $zip->numFiles .'.log')) {
85
+            if ($zip->addFile($logFile, date('Y-m-d').'-'.$zip->numFiles.'.log')) {
86 86
                 array_push($this->removeFiles, $logFile);
87 87
             }
88 88
             if (\is_dir($this->getConfig('save-pack-path'))) {
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             $zip->close();
97 97
         } else {
98 98
             if (is_file($logFile) && file_exists($logFile)) {
99
-                rename($logFile, $this->getConfig('save-path') . '/' . date('Y-m-d'). '-'. substr(md5_file($logFile), 0, 8).'.log');
99
+                rename($logFile, $this->getConfig('save-path').'/'.date('Y-m-d').'-'.substr(md5_file($logFile), 0, 8).'.log');
100 100
             }
101 101
         }
102 102
     }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      */
109 109
     protected function checkSize():bool
110 110
     {
111
-        $logFile= $this->latest;
111
+        $logFile = $this->latest;
112 112
         if (file_exists($logFile)) {
113 113
             if (filesize($logFile) > $this->getConfig('max-file-size')) {
114 114
                 return true;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
     public function log($level, string $message, array $context = [])
122 122
     {
123
-        if (LogLevel::compare($level, $this->getConfig('log-level')) >=0) {
123
+        if (LogLevel::compare($level, $this->getConfig('log-level')) >= 0) {
124 124
             $replace = [];
125 125
             $message = $this->interpolate($message, $context);
126 126
             $replace['%level%'] = $level;
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
     protected function rollLatest()
134 134
     {
135 135
         if (isset($this->latest)) {
136
-            $size=ftell($this->temp);
136
+            $size = ftell($this->temp);
137 137
             fseek($this->temp, 0);
138 138
             if ($size > 0) {
139
-                $body=fread($this->temp, $size);
139
+                $body = fread($this->temp, $size);
140 140
                 file_put_contents($this->latest, $body, FILE_APPEND);
141 141
             }
142 142
             fclose($this->temp);
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     {
169 169
         $replace = [];
170 170
         foreach ($context as $key => $val) {
171
-            $replace['{' . $key . '}'] = $val;
171
+            $replace['{'.$key.'}'] = $val;
172 172
         }
173 173
         return strtr($message, $replace);
174 174
     }
Please login to merge, or discard this patch.
nebula/component/template/Template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  */
7 7
 interface Template
8 8
 {
9
-    public function get(string $name=null, $default=null);
9
+    public function get(string $name = null, $default = null);
10 10
     public function set(string $name, $value);
11 11
     public function has(string $name);
12 12
     public function assign(array $values);
Please login to merge, or discard this patch.
nebula/component/template/TemplateLoader.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
     
51 51
     public static function credibleLoad(string $name): Template
52 52
     {
53
-        if (($template = static::load($name))!==null) {
53
+        if (($template = static::load($name)) !== null) {
54 54
             return $template;
55 55
         }
56 56
         $empty = new EmptyTemplate;
Please login to merge, or discard this patch.