@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Micro |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Micro |