Completed
Push — master ( a7d2c4...bd1769 )
by Niels
04:06
created
src/DirectAdmin/Context/ResellerContext.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@
 block discarded – undo
83 83
     public function deleteAccounts(array $usernames)
84 84
     {
85 85
         $options = ['confirmed' => 'Confirm', 'delete' => 'yes'];
86
-        foreach (array_values($usernames) as $idx => $username) {
86
+        foreach(array_values($usernames) as $idx => $username) {
87 87
             $options["select{$idx}"] = $username;
88 88
         }
89 89
         $this->invokePost('SELECT_USERS', $options);
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,8 @@
 block discarded – undo
83 83
     public function deleteAccounts(array $usernames)
84 84
     {
85 85
         $options = ['confirmed' => 'Confirm', 'delete' => 'yes'];
86
-        foreach (array_values($usernames) as $idx => $username) {
86
+        foreach (array_values($usernames) as $idx => $username)
87
+        {
87 88
             $options["select{$idx}"] = $username;
88 89
         }
89 90
         $this->invokePost('SELECT_USERS', $options);
Please login to merge, or discard this patch.
src/DirectAdmin/Context/UserContext.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
     public function __construct(DirectAdmin $connection, $validate = false)
35 35
     {
36 36
         parent::__construct($connection);
37
-        if ($validate) {
37
+        if($validate) {
38 38
             $classMap = [
39 39
                 DirectAdmin::ACCOUNT_TYPE_ADMIN => AdminContext::class,
40 40
                 DirectAdmin::ACCOUNT_TYPE_RESELLER => ResellerContext::class,
41 41
                 DirectAdmin::ACCOUNT_TYPE_USER => self::class,
42 42
             ];
43
-            if ($classMap[$this->getType()] != get_class($this)) {
43
+            if($classMap[$this->getType()] != get_class($this)) {
44 44
                 throw new DirectAdminException('Validation mismatch on context construction');
45 45
             }
46 46
         }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      */
64 64
     public function getContextUser()
65 65
     {
66
-        if (!isset($this->user)) {
66
+        if(!isset($this->user)) {
67 67
             $this->user = User::fromConfig($this->invokeGet('SHOW_USER_CONFIG'), $this);
68 68
         }
69 69
         return $this->user;
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,13 +34,15 @@  discard block
 block discarded – undo
34 34
     public function __construct(DirectAdmin $connection, $validate = false)
35 35
     {
36 36
         parent::__construct($connection);
37
-        if ($validate) {
37
+        if ($validate)
38
+        {
38 39
             $classMap = [
39 40
                 DirectAdmin::ACCOUNT_TYPE_ADMIN => AdminContext::class,
40 41
                 DirectAdmin::ACCOUNT_TYPE_RESELLER => ResellerContext::class,
41 42
                 DirectAdmin::ACCOUNT_TYPE_USER => self::class,
42 43
             ];
43
-            if ($classMap[$this->getType()] != get_class($this)) {
44
+            if ($classMap[$this->getType()] != get_class($this))
45
+            {
44 46
                 throw new DirectAdminException('Validation mismatch on context construction');
45 47
             }
46 48
         }
@@ -63,7 +65,8 @@  discard block
 block discarded – undo
63 65
      */
64 66
     public function getContextUser()
65 67
     {
66
-        if (!isset($this->user)) {
68
+        if (!isset($this->user))
69
+        {
67 70
             $this->user = User::fromConfig($this->invokeGet('SHOW_USER_CONFIG'), $this);
68 71
         }
69 72
         return $this->user;
Please login to merge, or discard this patch.
src/DirectAdmin/Objects/DomainObject.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
      */
71 71
     public static function toDomainObjectArray(array $items, $class, Domain $domain)
72 72
     {
73
-        array_walk($items, function (&$value, $name) use ($class, $domain) {
73
+        array_walk($items, function(&$value, $name) use ($class, $domain) {
74 74
             $value = new $class($name, $domain, $value);
75 75
         });
76 76
         return $items;
Please login to merge, or discard this patch.
src/DirectAdmin/Objects/Object.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/Users/Reseller.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
     public function impersonate()
57 57
     {
58 58
         /** @var AdminContext $context */
59
-        if (!($context = $this->getContext()) instanceof AdminContext) {
59
+        if(!($context = $this->getContext()) instanceof AdminContext) {
60 60
             throw new DirectAdminException('You need to be an admin to impersonate a reseller');
61 61
         }
62 62
         return $context->impersonateReseller($this->getUsername());
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,8 @@
 block discarded – undo
56 56
     public function impersonate()
57 57
     {
58 58
         /** @var AdminContext $context */
59
-        if (!($context = $this->getContext()) instanceof AdminContext) {
59
+        if (!($context = $this->getContext()) instanceof AdminContext)
60
+        {
60 61
             throw new DirectAdminException('You need to be an admin to impersonate a reseller');
61 62
         }
62 63
         return $context->impersonateReseller($this->getUsername());
Please login to merge, or discard this patch.
src/DirectAdmin/Objects/Users/User.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public function __construct($name, UserContext $context, $config = null)
44 44
     {
45 45
         parent::__construct($name, $context);
46
-        if (isset($config)) {
46
+        if(isset($config)) {
47 47
             $this->setCache(self::CACHE_CONFIG, $config);
48 48
         }
49 49
     }
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      */
164 164
     public function getDefaultDomain()
165 165
     {
166
-        if (empty($name = $this->getConfig('domain'))) {
166
+        if(empty($name = $this->getConfig('domain'))) {
167 167
             return null;
168 168
         }
169 169
         return $this->getDomain($name);
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
      */
205 205
     public function getDatabases()
206 206
     {
207
-        return $this->getCache(self::CACHE_DATABASES, function () {
207
+        return $this->getCache(self::CACHE_DATABASES, function() {
208 208
             $databases = [];
209
-            foreach ($this->getSelfManagedContext()->invokeGet('DATABASES') as $fullName) {
209
+            foreach($this->getSelfManagedContext()->invokeGet('DATABASES') as $fullName) {
210 210
                 list($user, $db) = explode('_', $fullName, 2);
211
-                if ($this->getUsername() != $user) {
211
+                if($this->getUsername() != $user) {
212 212
                     throw new DirectAdminException('Username incorrect on database ' . $fullName);
213 213
                 }
214 214
                 $databases[$db] = new Database($db, $this, $this->getSelfManagedContext());
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      */
224 224
     public function getDomain($domainName)
225 225
     {
226
-        if (!isset($this->domains)) {
226
+        if(!isset($this->domains)) {
227 227
             $this->getDomains();
228 228
         }
229 229
         return isset($this->domains[$domainName]) ? $this->domains[$domainName] : null;
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
      */
235 235
     public function getDomains()
236 236
     {
237
-        if (!isset($this->domains)) {
238
-            if (!$this->isSelfManaged()) {
237
+        if(!isset($this->domains)) {
238
+            if(!$this->isSelfManaged()) {
239 239
                 $this->domains = $this->impersonate()->getDomains();
240 240
             } else {
241 241
                 $this->domains = Object::toRichObjectArray($this->getContext()->invokeGet('ADDITIONAL_DOMAINS'), Domain::class, $this->getContext());
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
     public function impersonate()
283 283
     {
284 284
         /** @var ResellerContext $context */
285
-        if (!($context = $this->getContext()) instanceof ResellerContext) {
285
+        if(!($context = $this->getContext()) instanceof ResellerContext) {
286 286
             throw new DirectAdminException('You need to be at least a reseller to impersonate');
287 287
         }
288 288
         return $context->impersonateUser($this->getUsername());
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
     public static function fromConfig($config, UserContext $context)
349 349
     {
350 350
         $name = $config['username'];
351
-        switch ($config['usertype']) {
351
+        switch($config['usertype']) {
352 352
             case DirectAdmin::ACCOUNT_TYPE_USER:
353 353
                 return new self($name, $context, $config);
354 354
             case DirectAdmin::ACCOUNT_TYPE_RESELLER:
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
      */
369 369
     private function getConfig($item)
370 370
     {
371
-        return $this->getCacheItem(self::CACHE_CONFIG, $item, function () {
371
+        return $this->getCacheItem(self::CACHE_CONFIG, $item, function() {
372 372
             return $this->loadConfig();
373 373
         });
374 374
     }
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
      */
382 382
     private function getUsage($item)
383 383
     {
384
-        return $this->getCacheItem(self::CACHE_USAGE, $item, function () {
384
+        return $this->getCacheItem(self::CACHE_USAGE, $item, function() {
385 385
             return $this->getContext()->invokeGet('SHOW_USER_USAGE', ['user' => $this->getUsername()]);
386 386
         });
387 387
     }
Please login to merge, or discard this patch.
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -43,7 +43,8 @@  discard block
 block discarded – undo
43 43
     public function __construct($name, UserContext $context, $config = null)
44 44
     {
45 45
         parent::__construct($name, $context);
46
-        if (isset($config)) {
46
+        if (isset($config))
47
+        {
47 48
             $this->setCache(self::CACHE_CONFIG, $config);
48 49
         }
49 50
     }
@@ -163,7 +164,8 @@  discard block
 block discarded – undo
163 164
      */
164 165
     public function getDefaultDomain()
165 166
     {
166
-        if (empty($name = $this->getConfig('domain'))) {
167
+        if (empty($name = $this->getConfig('domain')))
168
+        {
167 169
             return null;
168 170
         }
169 171
         return $this->getDomain($name);
@@ -206,9 +208,11 @@  discard block
 block discarded – undo
206 208
     {
207 209
         return $this->getCache(self::CACHE_DATABASES, function () {
208 210
             $databases = [];
209
-            foreach ($this->getSelfManagedContext()->invokeGet('DATABASES') as $fullName) {
211
+            foreach ($this->getSelfManagedContext()->invokeGet('DATABASES') as $fullName)
212
+            {
210 213
                 list($user, $db) = explode('_', $fullName, 2);
211
-                if ($this->getUsername() != $user) {
214
+                if ($this->getUsername() != $user)
215
+                {
212 216
                     throw new DirectAdminException('Username incorrect on database ' . $fullName);
213 217
                 }
214 218
                 $databases[$db] = new Database($db, $this, $this->getSelfManagedContext());
@@ -223,7 +227,8 @@  discard block
 block discarded – undo
223 227
      */
224 228
     public function getDomain($domainName)
225 229
     {
226
-        if (!isset($this->domains)) {
230
+        if (!isset($this->domains))
231
+        {
227 232
             $this->getDomains();
228 233
         }
229 234
         return isset($this->domains[$domainName]) ? $this->domains[$domainName] : null;
@@ -234,10 +239,14 @@  discard block
 block discarded – undo
234 239
      */
235 240
     public function getDomains()
236 241
     {
237
-        if (!isset($this->domains)) {
238
-            if (!$this->isSelfManaged()) {
242
+        if (!isset($this->domains))
243
+        {
244
+            if (!$this->isSelfManaged())
245
+            {
239 246
                 $this->domains = $this->impersonate()->getDomains();
240
-            } else {
247
+            }
248
+            else
249
+            {
241 250
                 $this->domains = Object::toRichObjectArray($this->getContext()->invokeGet('ADDITIONAL_DOMAINS'), Domain::class, $this->getContext());
242 251
             }
243 252
         }
@@ -282,7 +291,8 @@  discard block
 block discarded – undo
282 291
     public function impersonate()
283 292
     {
284 293
         /** @var ResellerContext $context */
285
-        if (!($context = $this->getContext()) instanceof ResellerContext) {
294
+        if (!($context = $this->getContext()) instanceof ResellerContext)
295
+        {
286 296
             throw new DirectAdminException('You need to be at least a reseller to impersonate');
287 297
         }
288 298
         return $context->impersonateUser($this->getUsername());
@@ -348,7 +358,8 @@  discard block
 block discarded – undo
348 358
     public static function fromConfig($config, UserContext $context)
349 359
     {
350 360
         $name = $config['username'];
351
-        switch ($config['usertype']) {
361
+        switch ($config['usertype'])
362
+        {
352 363
             case DirectAdmin::ACCOUNT_TYPE_USER:
353 364
                 return new self($name, $context, $config);
354 365
             case DirectAdmin::ACCOUNT_TYPE_RESELLER:
Please login to merge, or discard this patch.
src/DirectAdmin/Objects/Users/Admin.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
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());
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,8 @@
 block discarded – undo
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 40
             throw new DirectAdminException('You need to be an admin to impersonate another admin');
40 41
         }
41 42
         return $context->impersonateAdmin($this->getUsername());
Please login to merge, or discard this patch.
src/DirectAdmin/Objects/Domain.php 2 patches
Spacing   +6 added lines, -6 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');
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
      */
220 220
     public function getDomainNames()
221 221
     {
222
-        return $this->getCache('domainNames', function () {
222
+        return $this->getCache('domainNames', function() {
223 223
             $list = array_merge($this->aliases, $this->pointers, [$this->getDomainName()]);
224 224
             sort($list);
225 225
             return $list;
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      */
232 232
     public function getForwarders()
233 233
     {
234
-        return $this->getCache(self::CACHE_FORWARDERS, function () {
234
+        return $this->getCache(self::CACHE_FORWARDERS, function() {
235 235
             $forwarders = $this->getContext()->invokeGet('EMAIL_FORWARDERS', [
236 236
                 'domain' => $this->getDomainName(),
237 237
             ]);
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
      */
245 245
     public function getMailboxes()
246 246
     {
247
-        return $this->getCache(self::CACHE_MAILBOXES, function () {
247
+        return $this->getCache(self::CACHE_MAILBOXES, function() {
248 248
             $boxes = $this->getContext()->invokeGet('POP', [
249 249
                 'domain' => $this->getDomainName(),
250 250
                 'action' => 'full_list',
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
      */
275 275
     public function getSubdomains()
276 276
     {
277
-        return $this->getCache(self::CACHE_SUBDOMAINS, function () {
277
+        return $this->getCache(self::CACHE_SUBDOMAINS, function() {
278 278
             $subs = $this->getContext()->invokeGet('SUBDOMAINS', ['domain' => $this->getDomainName()]);
279 279
             $subs = array_combine($subs, $subs);
280 280
             return DomainObject::toDomainObjectArray($subs, Subdomain::class, $this);
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
             'action' => $action,
297 297
             'domain' => $this->domainName,
298 298
         ], $parameters));
299
-        if ($clearCache) {
299
+        if($clearCache) {
300 300
             $this->clearCache();
301 301
         }
302 302
         return $response;
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 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
 
@@ -296,7 +299,8 @@  discard block
 block discarded – undo
296 299
             'action' => $action,
297 300
             'domain' => $this->domainName,
298 301
         ], $parameters));
299
-        if ($clearCache) {
302
+        if ($clearCache)
303
+        {
300 304
             $this->clearCache();
301 305
         }
302 306
         return $response;
Please login to merge, or discard this patch.
src/DirectAdmin/Objects/Email/Mailbox.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     public function __construct($prefix, Domain $domain, $config = null)
32 32
     {
33 33
         parent::__construct($prefix, $domain);
34
-        if (isset($config)) {
34
+        if(isset($config)) {
35 35
             $this->setCache(self::CACHE_DATA, is_string($config) ? \GuzzleHttp\Psr7\parse_query($config) : $config);
36 36
         }
37 37
     }
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      */
119 119
     protected function getData($key)
120 120
     {
121
-        return $this->getCacheItem(self::CACHE_DATA, $key, function () {
121
+        return $this->getCacheItem(self::CACHE_DATA, $key, function() {
122 122
             $result = $this->getContext()->invokeGet('POP', [
123 123
                 'domain' => $this->getDomainName(),
124 124
                 'action' => 'full_list',
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,8 @@
 block discarded – undo
31 31
     public function __construct($prefix, Domain $domain, $config = null)
32 32
     {
33 33
         parent::__construct($prefix, $domain);
34
-        if (isset($config)) {
34
+        if (isset($config))
35
+        {
35 36
             $this->setCache(self::CACHE_DATA, is_string($config) ? \GuzzleHttp\Psr7\parse_query($config) : $config);
36 37
         }
37 38
     }
Please login to merge, or discard this patch.