Completed
Push — master ( 281aed...d4d552 )
by
unknown
03:01
created
src/Log/Adapter/AbstractAdapter.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 /**
5 5
  * Micro
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      * @param Iterable $options
54 54
      * @return void
55 55
      */
56
-    public function __construct(?Iterable $config=null)
56
+    public function __construct(? Iterable $config = null)
57 57
     {
58 58
         $this->setOptions($config);
59 59
     }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      * @param   Iterable $options
97 97
      * @return  AdapterInterface
98 98
      */
99
-    public function setOptions(?Iterable $config=null): AdapterInterface
99
+    public function setOptions(? Iterable $config = null) : AdapterInterface
100 100
     {
101 101
         if ($config === null) {
102 102
             return $this;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
                 break;
110 110
                
111 111
                 case 'level':
112
-                    if(!is_numeric($val)) {
112
+                    if (!is_numeric($val)) {
113 113
                         throw new Exception('log level must be a number');
114 114
                     }
115 115
 
Please login to merge, or discard this patch.
tests/MockLogger.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
 {
8 8
     public $storage = [];
9 9
 
10
-    public function log($level, $message, array $context=[])
10
+    public function log($level, $message, array $context = [])
11 11
     {
12 12
         $this->storage[] = [
13 13
             'level'     => $level,
Please login to merge, or discard this patch.
src/Log.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 /**
5 5
  * Micro
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      * @param   Iterable $config
58 58
      * @return  void
59 59
      */
60
-    public function __construct(?Iterable $config=null)
60
+    public function __construct(? Iterable $config = null)
61 61
     {
62 62
         $this->setOptions($config);
63 63
     }
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
      * @param  Iterable $config
70 70
      * @return Log
71 71
      */
72
-    public function setOptions(?Iterable $config=null)
72
+    public function setOptions(? Iterable $config = null)
73 73
     {
74
-        if($config === null) {
74
+        if ($config === null) {
75 75
             return $this;
76 76
         }
77 77
 
78
-        foreach($config as $option => $value) {
79
-            if(!isset($value['enabled']) || $value['enabled'] === '1') {
78
+        foreach ($config as $option => $value) {
79
+            if (!isset($value['enabled']) || $value['enabled'] === '1') {
80 80
                 $this->addAdapter($option, $value['class'], $value['config']);
81 81
             }
82 82
         }
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
      * @param  Iterable $config
106 106
      * @return AdapterInterface
107 107
      */
108
-    public function addAdapter(string $name, string $class, ?Iterable $config=null): AdapterInterface
108
+    public function addAdapter(string $name, string $class, ? Iterable $config = null) : AdapterInterface
109 109
     {
110
-        if($this->hasAdapter($name)) {
110
+        if ($this->hasAdapter($name)) {
111 111
             throw new Exception('log adapter '.$name.' is already registered');
112 112
         }
113 113
             
114 114
         $adapter = new $class($config);
115
-        if(!($adapter instanceof AdapterInterface)) {
115
+        if (!($adapter instanceof AdapterInterface)) {
116 116
             throw new Exception('log adapter must include AdapterInterface interface');
117 117
         }
118 118
         $this->adapter[$name] = $adapter;
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      */
129 129
     public function getAdapter(string $name): AdapterInterface
130 130
     {
131
-        if(!$this->hasAdapter($name)) {
131
+        if (!$this->hasAdapter($name)) {
132 132
             throw new Exception('log adapter '.$name.' is not registered');
133 133
         }
134 134
 
@@ -142,14 +142,14 @@  discard block
 block discarded – undo
142 142
      * @param  array $adapters
143 143
      * @return array
144 144
      */
145
-    public function getAdapters(array $adapters=[]): array
145
+    public function getAdapters(array $adapters = []): array
146 146
     {
147
-        if(empty($adapter)) {
147
+        if (empty($adapter)) {
148 148
             return $this->adapter;
149 149
         } else {
150 150
             $list = [];
151
-            foreach($adapter as $name) {
152
-                if(!$this->hasAdapter($name)) {
151
+            foreach ($adapter as $name) {
152
+                if (!$this->hasAdapter($name)) {
153 153
                     throw new Exception('log adapter '.$name.' is not registered');
154 154
                 }
155 155
                 $list[$name] = $this->adapter[$name];
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      * @param   array $context
170 170
      * @return  bool
171 171
      */
172
-    public function log($level, $message, array $context=[]): bool
172
+    public function log($level, $message, array $context = []): bool
173 173
     {
174 174
         if (!array_key_exists($level, self::PRIORITIES)) {
175 175
             throw new Exception('log level '.$level.' is unkown');
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
      * @param   array $context
213 213
      * @return  void
214 214
      */
215
-    protected function _format(string $message, string $format, string $date_format, string $level, array $context=[]): string
215
+    protected function _format(string $message, string $format, string $date_format, string $level, array $context = []): string
216 216
     {
217
-        $parsed = preg_replace_callback('/(\{(([a-z]\.*)+)\})/', function ($match) use ($message, $level, $date_format, $context) {
217
+        $parsed = preg_replace_callback('/(\{(([a-z]\.*)+)\})/', function($match) use ($message, $level, $date_format, $context) {
218 218
             $key = '';
219 219
             $context = array_merge($this->context, $context);
220 220
                     
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
                     $replace = [];
238 238
                     foreach ($context as $key => $val) {
239 239
                         if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) {
240
-                            $replace['{' . $key . '}'] = $val;
240
+                            $replace['{'.$key.'}'] = $val;
241 241
                         } else {
242
-                            $replace['{' . $key . '}'] = json_encode($val);
242
+                            $replace['{'.$key.'}'] = json_encode($val);
243 243
                         }
244 244
                     }
245 245
 
Please login to merge, or discard this patch.
src/Log/Adapter/File.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 /**
5 5
  * Micro
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      * @param   Iterable $options
35 35
      * @return  AdapterInterface
36 36
      */
37
-    public function setOptions(?Iterable $config=null): AdapterInterface
37
+    public function setOptions(? Iterable $config = null) : AdapterInterface
38 38
     {
39 39
         parent::setOptions($config);
40 40
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function log(string $priority, string $message): bool
67 67
     {
68
-        if(!is_resource($this->resource)) {
68
+        if (!is_resource($this->resource)) {
69 69
             return false;
70 70
         }
71 71
 
Please login to merge, or discard this patch.