Passed
Push — master ( 92b22a...c0cf2f )
by Robbie
04:26
created
src/Services/LDAPService.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @var array
48 48
      */
49 49
     private static $dependencies = [
50
-        'gateway' => '%$' . LDAPGateway::class
50
+        'gateway' => '%$'.LDAPGateway::class
51 51
     ];
52 52
 
53 53
     /**
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public static function get_cache()
125 125
     {
126
-        return Injector::inst()->get(CacheInterface::class . '.ldap');
126
+        return Injector::inst()->get(CacheInterface::class.'.ldap');
127 127
     }
128 128
 
129 129
     /**
@@ -192,14 +192,14 @@  discard block
 block discarded – undo
192 192
         // show better errors than the defaults for various status codes returned by LDAP
193 193
         if (!empty($messages[1]) && strpos($messages[1], 'NT_STATUS_ACCOUNT_LOCKED_OUT') !== false) {
194 194
             $message = _t(
195
-                __CLASS__ . '.ACCOUNTLOCKEDOUT',
196
-                'Your account has been temporarily locked because of too many failed login attempts. ' .
195
+                __CLASS__.'.ACCOUNTLOCKEDOUT',
196
+                'Your account has been temporarily locked because of too many failed login attempts. '.
197 197
                 'Please try again later.'
198 198
             );
199 199
         }
200 200
         if (!empty($messages[1]) && strpos($messages[1], 'NT_STATUS_LOGON_FAILURE') !== false) {
201 201
             $message = _t(
202
-                __CLASS__ . '.INVALIDCREDENTIALS',
202
+                __CLASS__.'.INVALIDCREDENTIALS',
203 203
                 'The provided details don\'t seem to be correct. Please try again.'
204 204
             );
205 205
         }
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     public function getNodes($cached = true, $attributes = [])
223 223
     {
224 224
         $cache = self::get_cache();
225
-        $cacheKey = 'nodes' . md5(implode('', $attributes));
225
+        $cacheKey = 'nodes'.md5(implode('', $attributes));
226 226
         $results = $cache->has($cacheKey);
227 227
 
228 228
         if (!$results || !$cached) {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
     {
253 253
         $searchLocations = $this->config()->groups_search_locations ?: [null];
254 254
         $cache = self::get_cache();
255
-        $cacheKey = 'groups' . md5(implode('', array_merge($searchLocations, $attributes)));
255
+        $cacheKey = 'groups'.md5(implode('', array_merge($searchLocations, $attributes)));
256 256
         $results = $cache->has($cacheKey);
257 257
 
258 258
         if (!$results || !$cached) {
@@ -520,13 +520,13 @@  discard block
 block discarded – undo
520 520
         }
521 521
 
522 522
         $member->IsExpired = ($data['useraccountcontrol'] & 2) == 2;
523
-        $member->LastSynced = (string)DBDatetime::now();
523
+        $member->LastSynced = (string) DBDatetime::now();
524 524
 
525 525
         foreach ($member->config()->ldap_field_mappings as $attribute => $field) {
526 526
             if (!isset($data[$attribute])) {
527 527
                 $this->getLogger()->notice(
528 528
                     sprintf(
529
-                        'Attribute %s configured in Member.ldap_field_mappings, ' .
529
+                        'Attribute %s configured in Member.ldap_field_mappings, '.
530 530
                                 'but no available attribute in AD data (GUID: %s, Member ID: %s)',
531 531
                         $attribute,
532 532
                         $data['objectguid'],
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
                 ) {
545 545
                     $this->getLogger()->debug(
546 546
                         sprintf(
547
-                            'Member field %s configured for thumbnailphoto AD attribute, but it isn\'t a ' .
547
+                            'Member field %s configured for thumbnailphoto AD attribute, but it isn\'t a '.
548 548
                             'valid relation to an Image class',
549 549
                             $field
550 550
                         )
@@ -554,8 +554,8 @@  discard block
 block discarded – undo
554 554
                 }
555 555
 
556 556
                 $filename = sprintf('thumbnailphoto-%s.jpg', $data['samaccountname']);
557
-                $path = ASSETS_DIR . '/' . $member->config()->ldap_thumbnail_path;
558
-                $absPath = BASE_PATH . '/' . $path;
557
+                $path = ASSETS_DIR.'/'.$member->config()->ldap_thumbnail_path;
558
+                $absPath = BASE_PATH.'/'.$path;
559 559
                 if (!file_exists($absPath)) {
560 560
                     Filesystem::makeFolder($absPath);
561 561
                 }
@@ -567,13 +567,13 @@  discard block
 block discarded – undo
567 567
                 }
568 568
 
569 569
                 // The image data is provided in raw binary.
570
-                file_put_contents($absPath . '/' . $filename, $data[$attribute]);
570
+                file_put_contents($absPath.'/'.$filename, $data[$attribute]);
571 571
                 $record = new $imageClass();
572 572
                 $record->Name = $filename;
573
-                $record->Filename = $path . '/' . $filename;
573
+                $record->Filename = $path.'/'.$filename;
574 574
                 $record->write();
575 575
 
576
-                $relationField = $field . 'ID';
576
+                $relationField = $field.'ID';
577 577
                 $member->{$relationField} = $record->ID;
578 578
             } else {
579 579
                 $member->$field = $data[$attribute];
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
             $group->Description = $data['description'];
720 720
         }
721 721
         $group->DN = $data['dn'];
722
-        $group->LastSynced = (string)DBDatetime::now();
722
+        $group->LastSynced = (string) DBDatetime::now();
723 723
         $group->write();
724 724
 
725 725
         // Mappings on this group are automatically maintained to contain just the group's DN.
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
                 ),
783 783
             ]);
784 784
         } catch (Exception $e) {
785
-            throw new ValidationException('LDAP synchronisation failure: ' . $e->getMessage());
785
+            throw new ValidationException('LDAP synchronisation failure: '.$e->getMessage());
786 786
         }
787 787
 
788 788
         $user = $this->getUserByUsername($member->Username);
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
                 'distinguishedname' => $dn
827 827
             ]);
828 828
         } catch (Exception $e) {
829
-            throw new ValidationException('LDAP group creation failure: ' . $e->getMessage());
829
+            throw new ValidationException('LDAP group creation failure: '.$e->getMessage());
830 830
         }
831 831
 
832 832
         $data = $this->getGroupByDN($dn);
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
             try {
992 992
                 $this->update($groupDn, ['member' => $members]);
993 993
             } catch (Exception $e) {
994
-                throw new ValidationException('LDAP group membership remove failure: ' . $e->getMessage());
994
+                throw new ValidationException('LDAP group membership remove failure: '.$e->getMessage());
995 995
             }
996 996
         }
997 997
     }
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
         try {
1018 1018
             $this->update($groupDn, ['member' => $members]);
1019 1019
         } catch (Exception $e) {
1020
-            throw new ValidationException('LDAP group membership add failure: ' . $e->getMessage());
1020
+            throw new ValidationException('LDAP group membership add failure: '.$e->getMessage());
1021 1021
         }
1022 1022
     }
1023 1023
 
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
         try {
1101 1101
             $this->delete($data['distinguishedname']);
1102 1102
         } catch (Exception $e) {
1103
-            throw new ValidationException('LDAP delete user failed: ' . $e->getMessage());
1103
+            throw new ValidationException('LDAP delete user failed: '.$e->getMessage());
1104 1104
         }
1105 1105
     }
1106 1106
 
Please login to merge, or discard this patch.