Completed
Push — master ( 746653...79ff26 )
by Niels
01:54
created
src/DirectAdmin/Context/UserContext.php 1 patch
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.
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/Users/User.php 1 patch
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.
src/DirectAdmin/Objects/Users/Admin.php 1 patch
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.
src/DirectAdmin/Objects/Email/Mailbox.php 1 patch
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.
src/DirectAdmin/Objects/Email/Forwarder.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
      */
78 78
     public function getAliases()
79 79
     {
80
-        return array_map(function ($domain) {
80
+        return array_map(function($domain) {
81 81
             return $this->getPrefix() . '@' . $domain;
82 82
         }, $this->getDomain()->getDomainNames());
83 83
     }
Please login to merge, or discard this patch.
src/DirectAdmin/Objects/Database.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
             'action' => 'create',
58 58
             'name' => $name,
59 59
         ];
60
-        if (!empty($password)) {
60
+        if(!empty($password)) {
61 61
             $options += ['user' => $username, 'passwd' => $password, 'passwd2' => $password];
62 62
         } else {
63 63
             $options += ['userlist' => $username];
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function getAccessHosts()
85 85
     {
86
-        return $this->getCache(self::CACHE_ACCESS_HOSTS, function () {
86
+        return $this->getCache(self::CACHE_ACCESS_HOSTS, function() {
87 87
             $accessHosts = $this->getContext()->invokeGet('DATABASES', [
88 88
                 'action' => 'accesshosts',
89 89
                 'db' => $this->getDatabaseName(),
90 90
             ]);
91 91
 
92
-            return array_map(function ($name) {
92
+            return array_map(function($name) {
93 93
                 return new Database\AccessHost($name, $this);
94 94
             }, $accessHosts);
95 95
         });
Please login to merge, or discard this patch.
src/DirectAdmin/Utility/Conversion.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     {
40 40
         $ukey = "u{$key}";
41 41
         unset($options[$ukey]);
42
-        if (array_key_exists($key, $options) && ($options[$key] === 'unlimited' || !isset($options[$key]))) {
42
+        if(array_key_exists($key, $options) && ($options[$key] === 'unlimited' || !isset($options[$key]))) {
43 43
             $options[$ukey] = 'ON';
44 44
         }
45 45
     }
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public static function processUnlimitedOptions(array $options)
54 54
     {
55
-        foreach (['bandwidth', 'domainptr', 'ftp', 'mysql', 'nemailf', 'nemailml', 'nemailr', 'nemails',
55
+        foreach(['bandwidth', 'domainptr', 'ftp', 'mysql', 'nemailf', 'nemailml', 'nemailr', 'nemails',
56 56
                     'nsubdomains', 'quota', 'vdomains', ] as $key) {
57 57
             self::processUnlimitedOption($options, $key);
58 58
         }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public static function responseToArray($data)
69 69
     {
70
-        $unescaped = preg_replace_callback('/&#([0-9]{2})/', function ($val) {
70
+        $unescaped = preg_replace_callback('/&#([0-9]{2})/', function($val) {
71 71
             return chr($val[1]);
72 72
         }, $data);
73 73
         return \GuzzleHttp\Psr7\parse_query($unescaped);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public static function sanitizeArray($result)
83 83
     {
84
-        if (count($result) == 1 && isset($result['list[]'])) {
84
+        if(count($result) == 1 && isset($result['list[]'])) {
85 85
             $result = $result['list[]'];
86 86
         }
87 87
         return is_array($result) ? $result : [$result];
Please login to merge, or discard this patch.
src/DirectAdmin/DirectAdmin.php 1 patch
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.