Passed
Pull Request — master (#194)
by
unknown
02:44
created
src/ClientManager.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -76,17 +76,17 @@  discard block
 block discarded – undo
76 76
     public static function get($key, $default = null) {
77 77
         $parts = explode('.', $key);
78 78
         $value = null;
79
-        foreach($parts as $part) {
80
-            if($value === null) {
81
-                if(isset(self::$config[$part])) {
79
+        foreach ($parts as $part) {
80
+            if ($value === null) {
81
+                if (isset(self::$config[$part])) {
82 82
                     $value = self::$config[$part];
83
-                }else{
83
+                }else {
84 84
                     break;
85 85
                 }
86
-            }else{
87
-                if(isset($value[$part])) {
86
+            }else {
87
+                if (isset($value[$part])) {
88 88
                     $value = $value[$part];
89
-                }else{
89
+                }else {
90 90
                     break;
91 91
                 }
92 92
             }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
      */
177 177
     public function setConfig($config) {
178 178
 
179
-        if(is_array($config) === false) {
179
+        if (is_array($config) === false) {
180 180
             $config = require $config;
181 181
         }
182 182
 
@@ -186,17 +186,17 @@  discard block
 block discarded – undo
186 186
         $vendor_config = require $path;
187 187
         $config = $this->array_merge_recursive_distinct($vendor_config, $config);
188 188
 
189
-        if(is_array($config)){
190
-            if(isset($config['default'])){
191
-                if(isset($config['accounts']) && $config['default'] != false){
189
+        if (is_array($config)) {
190
+            if (isset($config['default'])) {
191
+                if (isset($config['accounts']) && $config['default'] != false) {
192 192
 
193 193
                     $default_config = $vendor_config['accounts']['default'];
194
-                    if(isset($config['accounts'][$config['default']])){
194
+                    if (isset($config['accounts'][$config['default']])) {
195 195
                         $default_config = array_merge($default_config, $config['accounts'][$config['default']]);
196 196
                     }
197 197
 
198
-                    if(is_array($config['accounts'])){
199
-                        foreach($config['accounts'] as $account_key => $account){
198
+                    if (is_array($config['accounts'])) {
199
+                        foreach ($config['accounts'] as $account_key => $account) {
200 200
                             $config['accounts'][$account_key] = array_merge($default_config, $account);
201 201
                         }
202 202
                     }
@@ -238,20 +238,20 @@  discard block
 block discarded – undo
238 238
             return array_keys($arr) !== range(0, count($arr) - 1);
239 239
         };
240 240
 
241
-        if(!is_array($base)) $base = empty($base) ? array() : array($base);
241
+        if (!is_array($base)) $base = empty($base) ? array() : array($base);
242 242
 
243
-        foreach($arrays as $append) {
243
+        foreach ($arrays as $append) {
244 244
 
245
-            if(!is_array($append)) $append = array($append);
245
+            if (!is_array($append)) $append = array($append);
246 246
 
247
-            foreach($append as $key => $value) {
247
+            foreach ($append as $key => $value) {
248 248
 
249
-                if(!array_key_exists($key, $base) and !is_numeric($key)) {
249
+                if (!array_key_exists($key, $base) and !is_numeric($key)) {
250 250
                     $base[$key] = $append[$key];
251 251
                     continue;
252 252
                 }
253 253
 
254
-                if(
254
+                if (
255 255
                     (
256 256
                         is_array($value)
257 257
                         && $isAssoc($value)
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
                     // else merging $baseConfig['dispositions'] = ['attachment', 'inline'] with $customConfig['dispositions'] = ['attachment']
266 266
                     // results in $resultConfig['dispositions'] = ['attachment', 'inline']
267 267
                     $base[$key] = $this->array_merge_recursive_distinct($base[$key], $append[$key]);
268
-                } else if(is_numeric($key)) {
269
-                    if(!in_array($value, $base)) $base[] = $value;
270
-                } else {
268
+                }else if (is_numeric($key)) {
269
+                    if (!in_array($value, $base)) $base[] = $value;
270
+                }else {
271 271
                     $base[$key] = $value;
272 272
                 }
273 273
 
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
             if($value === null) {
81 81
                 if(isset(self::$config[$part])) {
82 82
                     $value = self::$config[$part];
83
-                }else{
83
+                } else{
84 84
                     break;
85 85
                 }
86
-            }else{
86
+            } else{
87 87
                 if(isset($value[$part])) {
88 88
                     $value = $value[$part];
89
-                }else{
89
+                } else{
90 90
                     break;
91 91
                 }
92 92
             }
@@ -234,15 +234,21 @@  discard block
 block discarded – undo
234 234
 
235 235
         // From https://stackoverflow.com/a/173479
236 236
         $isAssoc = function(array $arr) {
237
-            if (array() === $arr) return false;
237
+            if (array() === $arr) {
238
+                return false;
239
+            }
238 240
             return array_keys($arr) !== range(0, count($arr) - 1);
239 241
         };
240 242
 
241
-        if(!is_array($base)) $base = empty($base) ? array() : array($base);
243
+        if(!is_array($base)) {
244
+            $base = empty($base) ? array() : array($base);
245
+        }
242 246
 
243 247
         foreach($arrays as $append) {
244 248
 
245
-            if(!is_array($append)) $append = array($append);
249
+            if(!is_array($append)) {
250
+                $append = array($append);
251
+            }
246 252
 
247 253
             foreach($append as $key => $value) {
248 254
 
@@ -266,7 +272,9 @@  discard block
 block discarded – undo
266 272
                     // results in $resultConfig['dispositions'] = ['attachment', 'inline']
267 273
                     $base[$key] = $this->array_merge_recursive_distinct($base[$key], $append[$key]);
268 274
                 } else if(is_numeric($key)) {
269
-                    if(!in_array($value, $base)) $base[] = $value;
275
+                    if(!in_array($value, $base)) {
276
+                        $base[] = $value;
277
+                    }
270 278
                 } else {
271 279
                     $base[$key] = $value;
272 280
                 }
Please login to merge, or discard this patch.
src/Part.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
      *
160 160
      * @throws InvalidMessageDateException
161 161
      */
162
-    protected function parse(){
162
+    protected function parse() {
163 163
         if ($this->header === null) {
164 164
             $body = $this->findHeaders();
165
-        }else{
165
+        }else {
166 166
             $body = $this->raw;
167 167
         }
168 168
 
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
         $this->name = $this->header->get("name");
175 175
         $this->filename = $this->header->get("filename");
176 176
 
177
-        if(!empty($this->header->get("id"))) {
177
+        if (!empty($this->header->get("id"))) {
178 178
             $this->id = $this->header->get("id");
179
-        } else if(!empty($this->header->get("x_attachment_id"))){
179
+        }else if (!empty($this->header->get("x_attachment_id"))) {
180 180
             $this->id = $this->header->get("x_attachment_id");
181
-        } else if(!empty($this->header->get("content_id"))){
181
+        }else if (!empty($this->header->get("content_id"))) {
182 182
             $this->id = strtr($this->header->get("content_id"), [
183 183
                 '<' => '',
184 184
                 '>' => ''
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         }
187 187
 
188 188
         $content_types = $this->header->get("content_type");
189
-        if(!empty($content_types)){
189
+        if (!empty($content_types)) {
190 190
             $this->subtype = $this->parseSubtype($content_types);
191 191
             $content_type = $content_types;
192 192
             if (is_array($content_types)) {
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
      * @return string
208 208
      * @throws InvalidMessageDateException
209 209
      */
210
-    private function findHeaders(){
210
+    private function findHeaders() {
211 211
         $body = $this->raw;
212 212
         while (($pos = strpos($body, "\r\n")) > 0) {
213 213
             $body = substr($body, $pos + 2);
@@ -226,16 +226,16 @@  discard block
 block discarded – undo
226 226
      *
227 227
      * @return string
228 228
      */
229
-    private function parseSubtype($content_type){
229
+    private function parseSubtype($content_type) {
230 230
         if (is_array($content_type)) {
231
-            foreach ($content_type as $part){
232
-                if ((strpos($part, "/")) !== false){
231
+            foreach ($content_type as $part) {
232
+                if ((strpos($part, "/")) !== false) {
233 233
                     return $this->parseSubtype($part);
234 234
                 }
235 235
             }
236 236
             return null;
237 237
         }
238
-        if (($pos = strpos($content_type, "/")) !== false){
238
+        if (($pos = strpos($content_type, "/")) !== false) {
239 239
             return substr($content_type, $pos + 1);
240 240
         }
241 241
         return null;
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
     /**
245 245
      * Try to parse the disposition if any is present
246 246
      */
247
-    private function parseDisposition(){
247
+    private function parseDisposition() {
248 248
         $content_disposition = $this->header->get("content_disposition");
249
-        if($content_disposition !== null) {
249
+        if ($content_disposition !== null) {
250 250
             $this->ifdisposition = true;
251 251
             $this->disposition = (is_array($content_disposition)) ? implode(' ', $content_disposition) : $content_disposition;
252 252
         }
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
     /**
256 256
      * Try to parse the description if any is present
257 257
      */
258
-    private function parseDescription(){
258
+    private function parseDescription() {
259 259
         $content_description = $this->header->get("content_description");
260
-        if($content_description !== null) {
260
+        if ($content_description !== null) {
261 261
             $this->ifdescription = true;
262 262
             $this->description = $content_description;
263 263
         }
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
     /**
267 267
      * Try to parse the encoding if any is present
268 268
      */
269
-    private function parseEncoding(){
269
+    private function parseEncoding() {
270 270
         $encoding = $this->header->get("content_transfer_encoding");
271
-        if($encoding !== null) {
271
+        if ($encoding !== null) {
272 272
             switch (strtolower($encoding)) {
273 273
                 case "quoted-printable":
274 274
                     $this->encoding = IMAP::MESSAGE_ENC_QUOTED_PRINTABLE;
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
      *
299 299
      * @return bool
300 300
      */
301
-    public function isAttachment(){
301
+    public function isAttachment() {
302 302
         $valid_disposition = in_array(strtolower($this->disposition), ClientManager::get('options.dispositions'));
303 303
 
304 304
         if ($this->type == IMAP::MESSAGE_TYPE_TEXT && ($this->ifdisposition == 0 || empty($this->disposition) || !$valid_disposition)) {
Please login to merge, or discard this patch.