@@ -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 |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @param Iterable $config |
| 97 | 97 | * @param Logger $logger |
| 98 | 98 | */ |
| 99 | - public function __construct(?Iterable $config, Logger $logger) |
|
| 99 | + public function __construct(? Iterable $config, Logger $logger) |
|
| 100 | 100 | { |
| 101 | 101 | $this->setOptions($config); |
| 102 | 102 | $this->logger = $logger; |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | $this->connection->set_charset($this->charset); |
| 115 | 115 | |
| 116 | 116 | if (!$this->connection->connect_errno) { |
| 117 | - $this->logger->info('connection to mysql server [' . $this->host . '] was succesful', [ |
|
| 117 | + $this->logger->info('connection to mysql server ['.$this->host.'] was succesful', [ |
|
| 118 | 118 | 'category' => get_class($this), |
| 119 | 119 | ]); |
| 120 | 120 | } else { |
| 121 | - throw new Exception('failed to connect to mysql server, error: ' . $this->connection->connect_error.' ('.$this->connection->connect_errno.')'); |
|
| 121 | + throw new Exception('failed to connect to mysql server, error: '.$this->connection->connect_error.' ('.$this->connection->connect_errno.')'); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | return $this; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * @param array $argumnets |
| 133 | 133 | * @return mixed |
| 134 | 134 | */ |
| 135 | - public function __call(string $method, array $arguments=[]) |
|
| 135 | + public function __call(string $method, array $arguments = []) |
|
| 136 | 136 | { |
| 137 | 137 | return call_user_func_array([&$this->connection, $method], $arguments); |
| 138 | 138 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @param Iterable $config |
| 145 | 145 | * @return Mysql |
| 146 | 146 | */ |
| 147 | - public function setOptions(?Iterable $config = null): Mysql |
|
| 147 | + public function setOptions(? Iterable $config = null) : Mysql |
|
| 148 | 148 | { |
| 149 | 149 | if ($config === null) { |
| 150 | 150 | return $this; |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | $link = $this->getResource(); |
| 208 | 208 | $result = $link->query($query); |
| 209 | 209 | |
| 210 | - if($result === false) { |
|
| 210 | + if ($result === false) { |
|
| 211 | 211 | throw new Exception('failed to execute sql query with error '.$link->error.' ('.$link->errno.')'); |
| 212 | 212 | } |
| 213 | 213 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | $link = $this->getResource(); |
| 231 | 231 | $result = $link->query($query); |
| 232 | 232 | |
| 233 | - if($result === false) { |
|
| 233 | + if ($result === false) { |
|
| 234 | 234 | throw new Exception('failed to execute sql query with error '.$link->error.' ('.$link->errno.')'); |
| 235 | 235 | } |
| 236 | 236 | |
@@ -255,19 +255,19 @@ discard block |
||
| 255 | 255 | $link = $this->getResource(); |
| 256 | 256 | $stmt = $link->prepare($query); |
| 257 | 257 | |
| 258 | - if(!($stmt instanceof mysqli_stmt)) { |
|
| 258 | + if (!($stmt instanceof mysqli_stmt)) { |
|
| 259 | 259 | throw new Exception('failed to prepare sql query with error '.$link->error.' ('.$link->errno.')'); |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | $types = ''; |
| 263 | - foreach($values as $attr => $value) { |
|
| 263 | + foreach ($values as $attr => $value) { |
|
| 264 | 264 | $types .= 's'; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | $stmt->bind_param($types, ...$values); |
| 268 | 268 | $stmt->execute(); |
| 269 | 269 | |
| 270 | - if($stmt->error) { |
|
| 270 | + if ($stmt->error) { |
|
| 271 | 271 | throw new Exception($stmt->error); |
| 272 | 272 | } |
| 273 | 273 | |
@@ -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 |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param string $env |
| 31 | 31 | * @return void |
| 32 | 32 | */ |
| 33 | - public function __construct(string $config, string $env='production') |
|
| 33 | + public function __construct(string $config, string $env = 'production') |
|
| 34 | 34 | { |
| 35 | 35 | $config = simplexml_load_file($config); |
| 36 | 36 | if ($this->store === false) { |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | while (list(, $node) = each($result)) { |
| 50 | 50 | $path = (string)$node->attributes()->inherits; |
| 51 | 51 | |
| 52 | - if($path === '') { |
|
| 52 | + if ($path === '') { |
|
| 53 | 53 | continue; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | * @param bool $replace |
| 87 | 87 | * @return bool |
| 88 | 88 | */ |
| 89 | - protected function appendSimplexml(SimpleXMLElement &$simplexml_to, SimpleXMLElement &$simplexml_from, bool $replace=true): bool |
|
| 89 | + protected function appendSimplexml(SimpleXMLElement&$simplexml_to, SimpleXMLElement&$simplexml_from, bool $replace = true): bool |
|
| 90 | 90 | { |
| 91 | - if(count($simplexml_from->children()) === 0) { |
|
| 92 | - if($replace === true && count($simplexml_to->children()) === 0) { |
|
| 91 | + if (count($simplexml_from->children()) === 0) { |
|
| 92 | + if ($replace === true && count($simplexml_to->children()) === 0) { |
|
| 93 | 93 | $simplexml_to[0] = htmlspecialchars((string)$simplexml_from); |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | foreach ($simplexml_from->attributes() as $attr_key => $attr_value) { |
| 99 | 99 | if (!isset($attrs[$attr_key])) { |
| 100 | 100 | $simplexml_to->addAttribute($attr_key, (string)$attr_value); |
| 101 | - } elseif($replace===true) { |
|
| 101 | + } elseif ($replace === true) { |
|
| 102 | 102 | $simplexml_to->attributes()->{$attr_key} = (string)$attr_value; |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | if (count($simplexml_child->children()) === 0) { |
| 108 | 108 | if (!isset($simplexml_to->{$simplexml_child->getName()})) { |
| 109 | 109 | $simplexml_to->addChild($simplexml_child->getName(), htmlspecialchars((string)$simplexml_child)); |
| 110 | - } elseif($replace === true && count($simplexml_to->{$simplexml_child->getName()}->children()) === 0) { |
|
| 110 | + } elseif ($replace === true && count($simplexml_to->{$simplexml_child->getName()}->children()) === 0) { |
|
| 111 | 111 | $simplexml_to->{$simplexml_child->getName()} = htmlspecialchars((string)$simplexml_child); |
| 112 | 112 | } |
| 113 | 113 | } else { |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | foreach ($simplexml_child->attributes() as $attr_key => $attr_value) { |
| 119 | 119 | if (!isset($attrs[$attr_key])) { |
| 120 | 120 | $simplexml_to->{$simplexml_child->getName()}->addAttribute($attr_key, (string)$attr_value); |
| 121 | - } elseif($replace===true) { |
|
| 121 | + } elseif ($replace === true) { |
|
| 122 | 122 | $simplexml_to->{$simplexml_child->getName()}->attributes()->{$attr_key} = (string)$attr_value; |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | while (list(, $node) = each($result)) { |
| 167 | 167 | $path = (string)$node->attributes()->reference; |
| 168 | 168 | |
| 169 | - if($path === '') { |
|
| 169 | + if ($path === '') { |
|
| 170 | 170 | continue; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * @param SimpleXMLElement $xml |
| 191 | 191 | * @return Config |
| 192 | 192 | */ |
| 193 | - public function map($xml=null): Config |
|
| 193 | + public function map($xml = null): Config |
|
| 194 | 194 | { |
| 195 | 195 | if ($xml === null) { |
| 196 | 196 | $xml = $this->store; |
@@ -200,10 +200,10 @@ discard block |
||
| 200 | 200 | foreach ($xml->getNamespaces() + array(null) as $prefix => $namespace) { |
| 201 | 201 | foreach ($xml->attributes($namespace) as $key => $value) { |
| 202 | 202 | if (is_string($prefix)) { |
| 203 | - $key = $prefix . '.' . $key; |
|
| 203 | + $key = $prefix.'.'.$key; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - if($key === 'reference') { |
|
| 206 | + if ($key === 'reference') { |
|
| 207 | 207 | continue; |
| 208 | 208 | } |
| 209 | 209 | |
@@ -217,13 +217,13 @@ discard block |
||
| 217 | 217 | if (!isset($arr[$name])) { |
| 218 | 218 | $config[$name] = $value; |
| 219 | 219 | } else { |
| 220 | - foreach ((array) $value as $k => $v) { |
|
| 220 | + foreach ((array)$value as $k => $v) { |
|
| 221 | 221 | if (is_numeric($k)) { |
| 222 | 222 | $config[$name][] = $v; |
| 223 | 223 | } else { |
| 224 | 224 | $config[$name][$k] = array_merge( |
| 225 | - (array) $config[$name][$k], |
|
| 226 | - (array) $v |
|
| 225 | + (array)$config[$name][$k], |
|
| 226 | + (array)$v |
|
| 227 | 227 | ); |
| 228 | 228 | } |
| 229 | 229 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | $config[$name] = new Config(); |
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | - if ($content = trim((string) $xml)) { |
|
| 235 | + if ($content = trim((string)$xml)) { |
|
| 236 | 236 | $config[] = $content; |
| 237 | 237 | } |
| 238 | 238 | |
@@ -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 |
@@ -56,5 +56,5 @@ discard block |
||
| 56 | 56 | * @param mixed $config |
| 57 | 57 | * @return Config |
| 58 | 58 | */ |
| 59 | - public function map($native=null): Config; |
|
| 59 | + public function map($native = null): Config; |
|
| 60 | 60 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param Iterable $config |
| 91 | 91 | * @param Logger $logger |
| 92 | 92 | */ |
| 93 | - public function __construct(?Iterable $config, Logger $logger) |
|
| 93 | + public function __construct(? Iterable $config, Logger $logger) |
|
| 94 | 94 | { |
| 95 | 95 | $this->setOptions($config); |
| 96 | 96 | $this->logger = $logger; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @param Iterable $config |
| 104 | 104 | * @return Moodle |
| 105 | 105 | */ |
| 106 | - public function setOptions(?Iterable $config): Moodle |
|
| 106 | + public function setOptions(? Iterable $config) : Moodle |
|
| 107 | 107 | { |
| 108 | 108 | if ($config === null) { |
| 109 | 109 | return $this; |
@@ -146,15 +146,15 @@ discard block |
||
| 146 | 146 | * @param string $function |
| 147 | 147 | * @return array |
| 148 | 148 | */ |
| 149 | - public function restCall(string $params, $function): ?array |
|
| 149 | + public function restCall(string $params, $function): ? array |
|
| 150 | 150 | { |
| 151 | - $url = $this->uri . |
|
| 152 | - '/webservice/rest/server.php?wstoken=' . $this->token . |
|
| 153 | - '&wsfunction=' . $function . |
|
| 154 | - '&moodlewsrestformat=' . $this->moodle_response_format . '&' . |
|
| 151 | + $url = $this->uri. |
|
| 152 | + '/webservice/rest/server.php?wstoken='.$this->token. |
|
| 153 | + '&wsfunction='.$function. |
|
| 154 | + '&moodlewsrestformat='.$this->moodle_response_format.'&'. |
|
| 155 | 155 | $params; |
| 156 | 156 | |
| 157 | - $this->logger->info('execute curl request [' . $url . ']', [ |
|
| 157 | + $this->logger->info('execute curl request ['.$url.']', [ |
|
| 158 | 158 | 'category' => get_class($this), |
| 159 | 159 | ]); |
| 160 | 160 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | $body = curl_exec($ch); |
| 169 | 169 | $http_code = curl_getinfo($ch)['http_code']; |
| 170 | 170 | if ($http_code !== 200) { |
| 171 | - throw new Exception('http request failed with response code ' . $http_code); |
|
| 171 | + throw new Exception('http request failed with response code '.$http_code); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | curl_close($ch); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | $body = json_decode($body); |
| 177 | 177 | |
| 178 | 178 | if (json_last_error() !== JSON_ERROR_NONE) { |
| 179 | - throw new Exception('failed decode moodle json response with error ' . json_last_error()); |
|
| 179 | + throw new Exception('failed decode moodle json response with error '.json_last_error()); |
|
| 180 | 180 | } elseif ($body instanceof StdClass && isset($body->exception)) { |
| 181 | 181 | if (isset($body->debuginfo)) { |
| 182 | 182 | $this->logger->debug($body->debuginfo, [ |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | ]); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - throw new Exception('moodle api request failed with exception ' . $body->message); |
|
| 187 | + throw new Exception('moodle api request failed with exception '.$body->message); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | return $body; |
@@ -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 |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param Iterable $config |
| 57 | 57 | * @return void |
| 58 | 58 | */ |
| 59 | - public function __construct(?Iterable $config=null) |
|
| 59 | + public function __construct(? Iterable $config = null) |
|
| 60 | 60 | { |
| 61 | 61 | $this->setOptions($config); |
| 62 | 62 | } |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | * @param Iterable $config |
| 69 | 69 | * @return Logger |
| 70 | 70 | */ |
| 71 | - public function setOptions(?Iterable $config=null) |
|
| 71 | + public function setOptions(? Iterable $config = null) |
|
| 72 | 72 | { |
| 73 | - if($config === null) { |
|
| 73 | + if ($config === null) { |
|
| 74 | 74 | return $this; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - foreach($config as $option => $value) { |
|
| 78 | - if(!isset($value['enabled']) || $value['enabled'] === '1') { |
|
| 77 | + foreach ($config as $option => $value) { |
|
| 78 | + if (!isset($value['enabled']) || $value['enabled'] === '1') { |
|
| 79 | 79 | $this->addAdapter($option, $value['class'], $value['config']); |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -92,14 +92,14 @@ discard block |
||
| 92 | 92 | * @param Iterable $config |
| 93 | 93 | * @return AdapterInterface |
| 94 | 94 | */ |
| 95 | - public function addAdapter(string $name, string $class, ?Iterable $config=null): AdapterInterface |
|
| 95 | + public function addAdapter(string $name, string $class, ? Iterable $config = null) : AdapterInterface |
|
| 96 | 96 | { |
| 97 | - if(isset($this->adapter[$name])) { |
|
| 97 | + if (isset($this->adapter[$name])) { |
|
| 98 | 98 | throw new Exception\InvalidArgument('log adapter '.$name.' is already registered'); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $adapter = new $class($config); |
| 102 | - if(!($adapter instanceof AdapterInterface)) { |
|
| 102 | + if (!($adapter instanceof AdapterInterface)) { |
|
| 103 | 103 | throw new Exception\InvalidArgument('log adapter must include AdapterInterface interface'); |
| 104 | 104 | } |
| 105 | 105 | $this->adapter[$name] = $adapter; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function getAdapter(string $name): AdapterInterface |
| 117 | 117 | { |
| 118 | - if(!isset($this->adapter[$name])) { |
|
| 118 | + if (!isset($this->adapter[$name])) { |
|
| 119 | 119 | throw new Exception('log adapter '.$name.' is not registered'); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -129,14 +129,14 @@ discard block |
||
| 129 | 129 | * @param array $adapters |
| 130 | 130 | * @return array |
| 131 | 131 | */ |
| 132 | - public function getAdapters(array $adapters=[]): array |
|
| 132 | + public function getAdapters(array $adapters = []): array |
|
| 133 | 133 | { |
| 134 | - if(empty($adapter)) { |
|
| 134 | + if (empty($adapter)) { |
|
| 135 | 135 | return $this->adapter; |
| 136 | 136 | } else { |
| 137 | 137 | $list = []; |
| 138 | - foreach($adapter as $name) { |
|
| 139 | - if(!isset($this->adapter[$name])) { |
|
| 138 | + foreach ($adapter as $name) { |
|
| 139 | + if (!isset($this->adapter[$name])) { |
|
| 140 | 140 | throw new Exception('log adapter '.$name.' is not registered'); |
| 141 | 141 | } |
| 142 | 142 | $list[$name] = $this->adapter[$name]; |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @param array $context |
| 157 | 157 | * @return bool |
| 158 | 158 | */ |
| 159 | - public function log($level, $message, array $context=[]): bool |
|
| 159 | + public function log($level, $message, array $context = []): bool |
|
| 160 | 160 | { |
| 161 | 161 | if (!array_key_exists($level, self::PRIORITIES)) { |
| 162 | 162 | throw new Exception\InvalidArgument('log level '.$level.' is unkown'); |
@@ -199,9 +199,9 @@ discard block |
||
| 199 | 199 | * @param array $context |
| 200 | 200 | * @return void |
| 201 | 201 | */ |
| 202 | - protected function _format(string $message, string $format, string $date_format, string $level, array $context=[]): string |
|
| 202 | + protected function _format(string $message, string $format, string $date_format, string $level, array $context = []): string |
|
| 203 | 203 | { |
| 204 | - $parsed = preg_replace_callback('/(\{(([a-z]\.*)+)\})/', function ($match) use ($message, $level, $date_format, $context) { |
|
| 204 | + $parsed = preg_replace_callback('/(\{(([a-z]\.*)+)\})/', function($match) use ($message, $level, $date_format, $context) { |
|
| 205 | 205 | $key = ''; |
| 206 | 206 | $context = array_merge($this->context, $context); |
| 207 | 207 | |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | $replace = []; |
| 225 | 225 | foreach ($context as $key => $val) { |
| 226 | 226 | if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) { |
| 227 | - $replace['{' . $key . '}'] = $val; |
|
| 227 | + $replace['{'.$key.'}'] = $val; |
|
| 228 | 228 | } else { |
| 229 | - $replace['{' . $key . '}'] = json_encode($val); |
|
| 229 | + $replace['{'.$key.'}'] = json_encode($val); |
|
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | |
@@ -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 |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @var bool |
| 70 | 70 | */ |
| 71 | - protected $tls=false; |
|
| 71 | + protected $tls = false; |
|
| 72 | 72 | |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @param Logger $logger |
| 87 | 87 | * @return resource |
| 88 | 88 | */ |
| 89 | - public function __construct(?Iterable $config, Logger $logger) |
|
| 89 | + public function __construct(? Iterable $config, Logger $logger) |
|
| 90 | 90 | { |
| 91 | 91 | $this->setOptions($config); |
| 92 | 92 | $this->logger = $logger; |
@@ -100,13 +100,13 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function connect(): Ldap |
| 102 | 102 | { |
| 103 | - if($this->binddn === null) { |
|
| 103 | + if ($this->binddn === null) { |
|
| 104 | 104 | $this->logger->warning('no binddn set for ldap connection, you should avoid anonymous bind', [ |
| 105 | 105 | 'category' => get_class($this), |
| 106 | 106 | ]); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if($this->tls === false || substr($this->uri, 0, 5) !== 'ldaps') { |
|
| 109 | + if ($this->tls === false || substr($this->uri, 0, 5) !== 'ldaps') { |
|
| 110 | 110 | $this->logger->warning('neither tls nor ldaps enabled for ldap connection, it is strongly reccommended to encrypt ldap connections', [ |
| 111 | 111 | 'category' => get_class($this), |
| 112 | 112 | ]); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | if ($this->connection) { |
| 126 | - if($this->binddn !== null) { |
|
| 126 | + if ($this->binddn !== null) { |
|
| 127 | 127 | $bind = ldap_bind($this->connection, $this->binddn, $this->bindpw); |
| 128 | 128 | |
| 129 | 129 | if ($bind) { |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * @param Iterable $config |
| 166 | 166 | * @return Ldap |
| 167 | 167 | */ |
| 168 | - public function setOptions(?Iterable $config=null): Ldap |
|
| 168 | + public function setOptions(? Iterable $config = null) : Ldap |
|
| 169 | 169 | { |
| 170 | 170 | if ($config === null) { |
| 171 | 171 | return $this; |
@@ -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 |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * @param Iterable $config |
| 56 | 56 | * @return void |
| 57 | 57 | */ |
| 58 | - public function __construct(?Iterable $config=null) |
|
| 58 | + public function __construct(? Iterable $config = null) |
|
| 59 | 59 | { |
| 60 | 60 | $this->setOptions($config); |
| 61 | 61 | } |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | * @param Iterable $config |
| 68 | 68 | * @return Logger |
| 69 | 69 | */ |
| 70 | - public function setOptions(?Iterable $config=null) |
|
| 70 | + public function setOptions(? Iterable $config = null) |
|
| 71 | 71 | { |
| 72 | - if($config === null) { |
|
| 72 | + if ($config === null) { |
|
| 73 | 73 | return $this; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - foreach($config as $option => $value) { |
|
| 77 | - if(isset($value['enabled']) && $value['enabled'] === '1') { |
|
| 76 | + foreach ($config as $option => $value) { |
|
| 77 | + if (isset($value['enabled']) && $value['enabled'] === '1') { |
|
| 78 | 78 | $this->addAdapter($option, $value['class'], $value['config']); |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -91,14 +91,14 @@ discard block |
||
| 91 | 91 | * @param Iterable $config |
| 92 | 92 | * @return AdapterInterface |
| 93 | 93 | */ |
| 94 | - public function addAdapter(string $name, string $class, ?Iterable $config=null): AdapterInterface |
|
| 94 | + public function addAdapter(string $name, string $class, ? Iterable $config = null) : AdapterInterface |
|
| 95 | 95 | { |
| 96 | - if(isset($this->adapter[$name])) { |
|
| 96 | + if (isset($this->adapter[$name])) { |
|
| 97 | 97 | throw new Exception\InvalidArgument('log adapter '.$name.' is already registered'); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $adapter = new $class($config); |
| 101 | - if(!($adapter instanceof AdapterInterface)) { |
|
| 101 | + if (!($adapter instanceof AdapterInterface)) { |
|
| 102 | 102 | throw new Exception\InvalidArgument('log adapter must include AdapterInterface interface'); |
| 103 | 103 | } |
| 104 | 104 | $this->adapter[$name] = $adapter; |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public function getAdapter(string $name): AdapterInterface |
| 116 | 116 | { |
| 117 | - if(!isset($this->adapter[$name])) { |
|
| 117 | + if (!isset($this->adapter[$name])) { |
|
| 118 | 118 | throw new Exception('log adapter '.$name.' is not registered'); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -128,14 +128,14 @@ discard block |
||
| 128 | 128 | * @param array $adapters |
| 129 | 129 | * @return array |
| 130 | 130 | */ |
| 131 | - public function getAdapters(array $adapters=[]): array |
|
| 131 | + public function getAdapters(array $adapters = []): array |
|
| 132 | 132 | { |
| 133 | - if(empty($adapter)) { |
|
| 133 | + if (empty($adapter)) { |
|
| 134 | 134 | return $this->adapter; |
| 135 | 135 | } else { |
| 136 | 136 | $list = []; |
| 137 | - foreach($adapter as $name) { |
|
| 138 | - if(!isset($this->adapter[$name])) { |
|
| 137 | + foreach ($adapter as $name) { |
|
| 138 | + if (!isset($this->adapter[$name])) { |
|
| 139 | 139 | throw new Exception('log adapter '.$name.' is not registered'); |
| 140 | 140 | } |
| 141 | 141 | $list[$name] = $this->adapter[$name]; |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * @param array $context |
| 156 | 156 | * @return bool |
| 157 | 157 | */ |
| 158 | - public function log($level, $message, array $context=[]): bool |
|
| 158 | + public function log($level, $message, array $context = []): bool |
|
| 159 | 159 | { |
| 160 | 160 | if (!array_key_exists($level, self::PRIORITIES)) { |
| 161 | 161 | throw new Exception\InvalidArgument('log level '.$level.' is unkown'); |
@@ -198,9 +198,9 @@ discard block |
||
| 198 | 198 | * @param array $context |
| 199 | 199 | * @return void |
| 200 | 200 | */ |
| 201 | - protected function _format(string $message, string $format, string $date_format, string $level, array $context=[]): string |
|
| 201 | + protected function _format(string $message, string $format, string $date_format, string $level, array $context = []): string |
|
| 202 | 202 | { |
| 203 | - $parsed = preg_replace_callback('/(\{(([a-z]\.*)+)\})/', function ($match) use ($message, $level, $date_format, $context) { |
|
| 203 | + $parsed = preg_replace_callback('/(\{(([a-z]\.*)+)\})/', function($match) use ($message, $level, $date_format, $context) { |
|
| 204 | 204 | $key = ''; |
| 205 | 205 | $context = array_merge($this->context, $context); |
| 206 | 206 | |
@@ -223,9 +223,9 @@ discard block |
||
| 223 | 223 | $replace = []; |
| 224 | 224 | foreach ($context as $key => $val) { |
| 225 | 225 | if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) { |
| 226 | - $replace['{' . $key . '}'] = $val; |
|
| 226 | + $replace['{'.$key.'}'] = $val; |
|
| 227 | 227 | } else { |
| 228 | - $replace['{' . $key . '}'] = json_encode($val); |
|
| 228 | + $replace['{'.$key.'}'] = json_encode($val); |
|
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | |
@@ -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 |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param string $config |
| 41 | 41 | * @return void |
| 42 | 42 | */ |
| 43 | - public function __construct($config=[]) |
|
| 43 | + public function __construct($config = []) |
|
| 44 | 44 | { |
| 45 | 45 | if ($config instanceof ConfigInterface) { |
| 46 | 46 | $this->store = $config->map(); |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Micro |