Completed
Push — master ( 9dfd32...d80879 )
by Niels
04:05
created
src/DirectAdmin/DirectAdmin.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -127,7 +127,8 @@  discard block
 block discarded – undo
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 132
             throw new DirectAdminException("$method to $command failed: $result[details] ($result[text])");
132 133
         }
133 134
         return Conversion::sanitizeArray($result);
@@ -155,14 +156,18 @@  discard block
 block discarded – undo
155 156
      */
156 157
     private function rawRequest($method, $uri, $options)
157 158
     {
158
-        try {
159
+        try
160
+        {
159 161
             $response = $this->connection->request($method, $uri, $options);
160
-            if ($response->getHeader('Content-Type')[0] == 'text/html') {
162
+            if ($response->getHeader('Content-Type')[0] == 'text/html')
163
+            {
161 164
                 throw new DirectAdminException("DirectAdmin API returned a text/html body. Requested {$uri} via {$method}. Responded: " . strip_tags($response->getBody()->getContents()));
162 165
             }
163 166
             $body = $response->getBody()->getContents();
164 167
             return Conversion::responseToArray($body);
165
-        } catch (TransferException $exception) {
168
+        }
169
+        catch (TransferException $exception)
170
+        {
166 171
             // Rethrow anything that causes a network issue
167 172
             throw new DirectAdminException("Request to {$uri} using {$method} failed", 0, $exception);
168 173
         }
Please login to merge, or discard this patch.
src/DirectAdmin/Objects/BaseObject.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,7 +56,8 @@  discard block
 block discarded – undo
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 61
             $this->cache[$key] = is_callable($default) ? $default() : $default;
61 62
         }
62 63
         return $this->cache[$key];
@@ -73,10 +74,12 @@  discard block
 block discarded – undo
73 74
      */
74 75
     protected function getCacheItem($key, $item, $defaultKey, $defaultItem = null)
75 76
     {
76
-        if (empty($cache = $this->getCache($key, $defaultKey))) {
77
+        if (empty($cache = $this->getCache($key, $defaultKey)))
78
+        {
77 79
             return $defaultItem;
78 80
         }
79
-        if (!is_array($cache)) {
81
+        if (!is_array($cache))
82
+        {
80 83
             throw new DirectAdminException("Cache item $key is not an array");
81 84
         }
82 85
         return isset($cache[$item]) ? $cache[$item] : $defaultItem;
Please login to merge, or discard this patch.
src/DirectAdmin/Objects/Domain.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         $this->domainName = $data['domain'];
70 70
 
71 71
         // Determine owner
72
-        if ($data['username'] === $context->getUsername()) {
72
+        if($data['username'] === $context->getUsername()) {
73 73
             $this->owner = $context->getContextUser();
74 74
         } else {
75 75
             throw new DirectAdminException('Could not determine relationship between context user and domain');
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
             'from' => $domain,
153 153
             'action' => 'add',
154 154
         ];
155
-        if ($alias) {
155
+        if($alias) {
156 156
             $parameters['alias'] = 'yes';
157 157
             $list = &$this->aliases;
158 158
         } else {
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
      */
244 244
     public function getDomainNames()
245 245
     {
246
-        return $this->getCache('domainNames', function () {
246
+        return $this->getCache('domainNames', function() {
247 247
             $list = array_merge($this->aliases, $this->pointers, [$this->getDomainName()]);
248 248
             sort($list);
249 249
             return $list;
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
      */
256 256
     public function getForwarders()
257 257
     {
258
-        return $this->getCache(self::CACHE_FORWARDERS, function () {
258
+        return $this->getCache(self::CACHE_FORWARDERS, function() {
259 259
             $forwarders = $this->getContext()->invokeGet('EMAIL_FORWARDERS', [
260 260
                 'domain' => $this->getDomainName(),
261 261
             ]);
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
      */
269 269
     public function getMailboxes()
270 270
     {
271
-        return $this->getCache(self::CACHE_MAILBOXES, function () {
271
+        return $this->getCache(self::CACHE_MAILBOXES, function() {
272 272
             $boxes = $this->getContext()->invokeGet('POP', [
273 273
                 'domain' => $this->getDomainName(),
274 274
                 'action' => 'full_list',
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
      */
299 299
     public function getSubdomains()
300 300
     {
301
-        return $this->getCache(self::CACHE_SUBDOMAINS, function () {
301
+        return $this->getCache(self::CACHE_SUBDOMAINS, function() {
302 302
             $subs = $this->getContext()->invokeGet('SUBDOMAINS', ['domain' => $this->getDomainName()]);
303 303
             $subs = array_combine($subs, $subs);
304 304
             return DomainObject::toDomainObjectArray($subs, Subdomain::class, $this);
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
             'action' => $action,
321 321
             'domain' => $this->domainName,
322 322
         ], $parameters));
323
-        if ($clearCache) {
323
+        if($clearCache) {
324 324
             $this->clearCache();
325 325
         }
326 326
         return $response;
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -69,9 +69,12 @@  discard block
 block discarded – undo
69 69
         $this->domainName = $data['domain'];
70 70
 
71 71
         // Determine owner
72
-        if ($data['username'] === $context->getUsername()) {
72
+        if ($data['username'] === $context->getUsername())
73
+        {
73 74
             $this->owner = $context->getContextUser();
74
-        } else {
75
+        }
76
+        else
77
+        {
75 78
             throw new DirectAdminException('Could not determine relationship between context user and domain');
76 79
         }
77 80
 
@@ -152,10 +155,13 @@  discard block
 block discarded – undo
152 155
             'from' => $domain,
153 156
             'action' => 'add',
154 157
         ];
155
-        if ($alias) {
158
+        if ($alias)
159
+        {
156 160
             $parameters['alias'] = 'yes';
157 161
             $list = &$this->aliases;
158
-        } else {
162
+        }
163
+        else
164
+        {
159 165
             $list = &$this->pointers;
160 166
         }
161 167
         $this->getContext()->invokePost('DOMAIN_POINTER', $parameters);
@@ -320,7 +326,8 @@  discard block
 block discarded – undo
320 326
             'action' => $action,
321 327
             'domain' => $this->domainName,
322 328
         ], $parameters));
323
-        if ($clearCache) {
329
+        if ($clearCache)
330
+        {
324 331
             $this->clearCache();
325 332
         }
326 333
         return $response;
Please login to merge, or discard this patch.