| @@ -1,5 +1,5 @@ discard block | ||
| 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 | ||
| 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 | ||
| 69 | 69 | * @param Iterable $config | 
| 70 | 70 | * @return Logger | 
| 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 | } | 
| @@ -93,14 +93,14 @@ discard block | ||
| 93 | 93 | * @param Iterable $config | 
| 94 | 94 | * @return AdapterInterface | 
| 95 | 95 | */ | 
| 96 | - public function addAdapter(string $name, string $class, ?Iterable $config=null): AdapterInterface | |
| 96 | + public function addAdapter(string $name, string $class, ? Iterable $config = null) : AdapterInterface | |
| 97 | 97 |      { | 
| 98 | -        if(isset($this->adapter[$name])) { | |
| 98 | +        if (isset($this->adapter[$name])) { | |
| 99 | 99 |              throw new Exception('log adapter '.$name.' is already registered'); | 
| 100 | 100 | } | 
| 101 | 101 | |
| 102 | 102 | $adapter = new $class($config); | 
| 103 | -        if(!($adapter instanceof AdapterInterface)) { | |
| 103 | +        if (!($adapter instanceof AdapterInterface)) { | |
| 104 | 104 |              throw new Exception('log adapter must include AdapterInterface interface'); | 
| 105 | 105 | } | 
| 106 | 106 | $this->adapter[$name] = $adapter; | 
| @@ -116,7 +116,7 @@ discard block | ||
| 116 | 116 | */ | 
| 117 | 117 | public function getAdapter(string $name): AdapterInterface | 
| 118 | 118 |      { | 
| 119 | -        if(!isset($this->adapter[$name])) { | |
| 119 | +        if (!isset($this->adapter[$name])) { | |
| 120 | 120 |              throw new Exception('log adapter '.$name.' is not registered'); | 
| 121 | 121 | } | 
| 122 | 122 | |
| @@ -130,14 +130,14 @@ discard block | ||
| 130 | 130 | * @param array $adapters | 
| 131 | 131 | * @return array | 
| 132 | 132 | */ | 
| 133 | - public function getAdapters(array $adapters=[]): array | |
| 133 | + public function getAdapters(array $adapters = []): array | |
| 134 | 134 |      { | 
| 135 | -        if(empty($adapter)) { | |
| 135 | +        if (empty($adapter)) { | |
| 136 | 136 | return $this->adapter; | 
| 137 | 137 |          } else { | 
| 138 | 138 | $list = []; | 
| 139 | -            foreach($adapter as $name) { | |
| 140 | -                if(!isset($this->adapter[$name])) { | |
| 139 | +            foreach ($adapter as $name) { | |
| 140 | +                if (!isset($this->adapter[$name])) { | |
| 141 | 141 |                      throw new Exception('log adapter '.$name.' is not registered'); | 
| 142 | 142 | } | 
| 143 | 143 | $list[$name] = $this->adapter[$name]; | 
| @@ -157,7 +157,7 @@ discard block | ||
| 157 | 157 | * @param array $context | 
| 158 | 158 | * @return bool | 
| 159 | 159 | */ | 
| 160 | - public function log($level, $message, array $context=[]): bool | |
| 160 | + public function log($level, $message, array $context = []): bool | |
| 161 | 161 |      { | 
| 162 | 162 |          if (!array_key_exists($level, self::PRIORITIES)) { | 
| 163 | 163 |              throw new Exception('log level '.$level.' is unkown'); | 
| @@ -200,9 +200,9 @@ discard block | ||
| 200 | 200 | * @param array $context | 
| 201 | 201 | * @return void | 
| 202 | 202 | */ | 
| 203 | - protected function _format(string $message, string $format, string $date_format, string $level, array $context=[]): string | |
| 203 | + protected function _format(string $message, string $format, string $date_format, string $level, array $context = []): string | |
| 204 | 204 |      { | 
| 205 | -        $parsed = preg_replace_callback('/(\{(([a-z]\.*)+)\})/', function ($match) use ($message, $level, $date_format, $context) { | |
| 205 | +        $parsed = preg_replace_callback('/(\{(([a-z]\.*)+)\})/', function($match) use ($message, $level, $date_format, $context) { | |
| 206 | 206 | $key = ''; | 
| 207 | 207 | $context = array_merge($this->context, $context); | 
| 208 | 208 | |
| @@ -225,9 +225,9 @@ discard block | ||
| 225 | 225 | $replace = []; | 
| 226 | 226 |                      foreach ($context as $key => $val) { | 
| 227 | 227 |                          if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) { | 
| 228 | -                            $replace['{' . $key . '}'] = $val; | |
| 228 | +                            $replace['{'.$key.'}'] = $val; | |
| 229 | 229 |                          } else { | 
| 230 | -                            $replace['{' . $key . '}'] = json_encode($val); | |
| 230 | +                            $replace['{'.$key.'}'] = json_encode($val); | |
| 231 | 231 | } | 
| 232 | 232 | } | 
| 233 | 233 | |
| @@ -1,5 +1,5 @@ discard block | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | |