@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | public function invoke($method, $command, $options = []) |
| 128 | 128 | { |
| 129 | 129 | $result = $this->rawRequest($method, '/CMD_API_' . $command, $options); |
| 130 | - if (!empty($result['error'])) { |
|
| 130 | + if(!empty($result['error'])) { |
|
| 131 | 131 | throw new DirectAdminException("$method to $command failed: $result[details] ($result[text])"); |
| 132 | 132 | } |
| 133 | 133 | return Conversion::sanitizeArray($result); |
@@ -157,12 +157,12 @@ discard block |
||
| 157 | 157 | { |
| 158 | 158 | try { |
| 159 | 159 | $response = $this->connection->request($method, $uri, $options); |
| 160 | - if ($response->getHeader('Content-Type')[0] == 'text/html') { |
|
| 160 | + if($response->getHeader('Content-Type')[0] == 'text/html') { |
|
| 161 | 161 | throw new DirectAdminException("DirectAdmin API returned a text/html body. Requested {$uri} via {$method}. Responded: " . strip_tags($response->getBody()->getContents())); |
| 162 | 162 | } |
| 163 | 163 | $body = $response->getBody()->getContents(); |
| 164 | 164 | return Conversion::responseToArray($body); |
| 165 | - } catch (TransferException $exception) { |
|
| 165 | + } catch(TransferException $exception) { |
|
| 166 | 166 | // Rethrow anything that causes a network issue |
| 167 | 167 | throw new DirectAdminException("Request to {$uri} using {$method} failed", 0, $exception); |
| 168 | 168 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | protected function getCache($key, $default) |
| 58 | 58 | { |
| 59 | - if (!isset($this->cache[$key])) { |
|
| 59 | + if(!isset($this->cache[$key])) { |
|
| 60 | 60 | $this->cache[$key] = is_callable($default) ? $default() : $default; |
| 61 | 61 | } |
| 62 | 62 | return $this->cache[$key]; |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | protected function getCacheItem($key, $item, $defaultKey, $defaultItem = null) |
| 75 | 75 | { |
| 76 | - if (empty($cache = $this->getCache($key, $defaultKey))) { |
|
| 76 | + if(empty($cache = $this->getCache($key, $defaultKey))) { |
|
| 77 | 77 | return $defaultItem; |
| 78 | 78 | } |
| 79 | - if (!is_array($cache)) { |
|
| 79 | + if(!is_array($cache)) { |
|
| 80 | 80 | throw new DirectAdminException("Cache item $key is not an array"); |
| 81 | 81 | } |
| 82 | 82 | return isset($cache[$item]) ? $cache[$item] : $defaultItem; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public static function toObjectArray(array $items, $class, UserContext $context) |
| 123 | 123 | { |
| 124 | - return array_combine($items, array_map(function ($item) use ($class, $context) { |
|
| 124 | + return array_combine($items, array_map(function($item) use ($class, $context) { |
|
| 125 | 125 | return new $class($item, $context); |
| 126 | 126 | }, $items)); |
| 127 | 127 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public static function toRichObjectArray(array $items, $class, UserContext $context) |
| 138 | 138 | { |
| 139 | - array_walk($items, function (&$value, $name) use ($class, $context) { |
|
| 139 | + array_walk($items, function(&$value, $name) use ($class, $context) { |
|
| 140 | 140 | $value = new $class($name, $context, $value); |
| 141 | 141 | }); |
| 142 | 142 | return $items; |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | public function impersonate() |
| 36 | 36 | { |
| 37 | 37 | /** @var AdminContext $context */ |
| 38 | - if (!($context = $this->getContext()) instanceof AdminContext) { |
|
| 38 | + if(!($context = $this->getContext()) instanceof AdminContext) { |
|
| 39 | 39 | throw new DirectAdminException('You need to be an admin to impersonate another admin'); |
| 40 | 40 | } |
| 41 | 41 | return $context->impersonateAdmin($this->getUsername()); |