@@ -39,7 +39,6 @@ |
||
39 | 39 | /** |
40 | 40 | * Set options |
41 | 41 | * |
42 | - * @param Iterable $options |
|
43 | 42 | * @return AdapterInterface |
44 | 43 | */ |
45 | 44 | public function setOptions(?Iterable $config=null) |
@@ -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 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param Iterable $options |
43 | 43 | * @return AdapterInterface |
44 | 44 | */ |
45 | - public function setOptions(?Iterable $config=null) |
|
45 | + public function setOptions(? Iterable $config = null) |
|
46 | 46 | { |
47 | 47 | parent::setOptions($options); |
48 | 48 |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Micro |
@@ -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 |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param array $params |
73 | 73 | * @return void |
74 | 74 | */ |
75 | - public function __construct(string $path, $class, ?string $method=null, array $params=[]) |
|
75 | + public function __construct(string $path, $class, ? string $method = null, array $params = []) |
|
76 | 76 | { |
77 | 77 | $this->setPath($path); |
78 | 78 | $this->setClass($class); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function match(): bool |
90 | 90 | { |
91 | - $regex = preg_replace_callback('#({([A-Z0-9a-z]+)\:\#(.+?)\#})|\{(.+?)\}#', function ($match) { |
|
91 | + $regex = preg_replace_callback('#({([A-Z0-9a-z]+)\:\#(.+?)\#})|\{(.+?)\}#', function($match) { |
|
92 | 92 | if (count($match) === 4) { |
93 | 93 | return '(?<'.$match[2].'>'.$match[3].'+)'; |
94 | 94 | } else { |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param array $constructor |
118 | 118 | * @return array |
119 | 119 | */ |
120 | - public function getCallable($constructor=[]): array |
|
120 | + public function getCallable($constructor = []): array |
|
121 | 121 | { |
122 | 122 | if (is_object($this->class)) { |
123 | 123 | $instance = $this->class; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @param string $name |
140 | 140 | * @return string |
141 | 141 | */ |
142 | - protected function _buildMethodName(?string $name): string |
|
142 | + protected function _buildMethodName(? string $name) : string |
|
143 | 143 | { |
144 | 144 | $result = $this->router->getVerb(); |
145 | 145 | |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * @param string $method |
265 | 265 | * @return Route |
266 | 266 | */ |
267 | - public function setMethod(?string $method): Route |
|
267 | + public function setMethod(? string $method) : Route |
|
268 | 268 | { |
269 | 269 | $this->method = $method; |
270 | 270 | return $this; |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @param bool $next |
313 | 313 | * @return Route |
314 | 314 | */ |
315 | - public function continuePropagation($next=true): Route |
|
315 | + public function continuePropagation($next = true): Route |
|
316 | 316 | { |
317 | 317 | $this->continue_propagation = (bool)$next; |
318 | 318 | 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 |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param Iterable $config |
79 | 79 | * @param Logger $logger |
80 | 80 | */ |
81 | - public function __construct(?Iterable $config, Logger $logger) |
|
81 | + public function __construct(? Iterable $config, Logger $logger) |
|
82 | 82 | { |
83 | 83 | $this->setOptions($config); |
84 | 84 | $this->logger = $logger; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | public function connect(): Pdo |
94 | 94 | { |
95 | 95 | $this->connection = new PdoServer($this->dsn, $this->username, $this->password, $this->options); |
96 | - $this->logger->info('connection to db server [' . $this->dsn . '] using pdo was succesful', [ |
|
96 | + $this->logger->info('connection to db server ['.$this->dsn.'] using pdo was succesful', [ |
|
97 | 97 | 'category' => get_class($this), |
98 | 98 | ]); |
99 | 99 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param array $argumnets |
109 | 109 | * @return mixed |
110 | 110 | */ |
111 | - public function __call(string $method, array $arguments=[]) |
|
111 | + public function __call(string $method, array $arguments = []) |
|
112 | 112 | { |
113 | 113 | return call_user_func_array([&$this->connection, $method], $arguments); |
114 | 114 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @param Iterable $config |
121 | 121 | * @return Pdo |
122 | 122 | */ |
123 | - public function setOptions(?Iterable $config = null): Pdo |
|
123 | + public function setOptions(? Iterable $config = null) : Pdo |
|
124 | 124 | { |
125 | 125 | if ($config === null) { |
126 | 126 | return $this; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $this->password = (string)$value; |
139 | 139 | break; |
140 | 140 | case 'options': |
141 | - foreach($value as $opt => $val) { |
|
141 | + foreach ($value as $opt => $val) { |
|
142 | 142 | $this->options[$opt] = (string)$val; |
143 | 143 | } |
144 | 144 | break; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $link = $this->getResource(); |
180 | 180 | $result = $link->query($query); |
181 | 181 | |
182 | - if($result === false) { |
|
182 | + if ($result === false) { |
|
183 | 183 | throw new Exception('failed to execute sql query with error '.$link->errorInfo()[2].' ('.$link->errorCode().')'); |
184 | 184 | } |
185 | 185 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $link = $this->getResource(); |
203 | 203 | $result = $link->exec($query); |
204 | 204 | |
205 | - if($result === false) { |
|
205 | + if ($result === false) { |
|
206 | 206 | throw new Exception('failed to execute sql query with error '.$link->errorInfo().' ('.$link->errorCode().')'); |
207 | 207 | } else { |
208 | 208 | $this->logger->debug('sql query affected ['.$result.'] rows', [ |
@@ -231,12 +231,12 @@ discard block |
||
231 | 231 | $link = $this->getResource(); |
232 | 232 | $stmt = $link->prepare($query); |
233 | 233 | |
234 | - if(!($stmt instanceof mysqli_stmt)) { |
|
234 | + if (!($stmt instanceof mysqli_stmt)) { |
|
235 | 235 | throw new Exception('failed to prepare mysql query with error '.$link->error.' ('.$link->errno.')'); |
236 | 236 | } |
237 | 237 | |
238 | 238 | $types = ''; |
239 | - foreach($values as $attr => $value) { |
|
239 | + foreach ($values as $attr => $value) { |
|
240 | 240 | $types .= 's'; |
241 | 241 | } |
242 | 242 |
@@ -129,7 +129,7 @@ |
||
129 | 129 | * Forward calls |
130 | 130 | * |
131 | 131 | * @param array $method |
132 | - * @param array $argumnets |
|
132 | + * @param array $arguments |
|
133 | 133 | * @return mixed |
134 | 134 | */ |
135 | 135 | public function __call(string $method, array $arguments=[]) |
@@ -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 |
@@ -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 |
@@ -197,7 +197,7 @@ |
||
197 | 197 | * @param string $date_format |
198 | 198 | * @param string $level |
199 | 199 | * @param array $context |
200 | - * @return void |
|
200 | + * @return string |
|
201 | 201 | */ |
202 | 202 | protected function _format(string $message, string $format, string $date_format, string $level, array $context=[]): string |
203 | 203 | { |
@@ -165,7 +165,7 @@ |
||
165 | 165 | foreach ($this->adapter as $adapter) { |
166 | 166 | $prio = $adapter->getLevel(); |
167 | 167 | |
168 | - if (self::PRIORITIES[$level] <= $prio) { |
|
168 | + if (self::PRIORITIES[$level] <= $prio) { |
|
169 | 169 | $msg = $this->_format($message, $adapter->getFormat(), $adapter->getDateFormat(), $level, $context); |
170 | 170 | $adapter->log($level, $msg); |
171 | 171 | } |
@@ -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 |