Passed
Push — master ( c5659f...8119c1 )
by Andre
09:07
created
src/elements/Provider.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function getFieldContext(): string
99 99
     {
100
-        return 'enupalSocializer:' . $this->id;
100
+        return 'enupalSocializer:'.$this->id;
101 101
     }
102 102
 
103 103
     /**
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
      */
108 108
     public static function displayName(): string
109 109
     {
110
-        return Craft::t('enupal-socializer','Socializer');
110
+        return Craft::t('enupal-socializer', 'Socializer');
111 111
     }
112 112
 
113 113
     /**
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     public function getCpEditUrl()
168 168
     {
169 169
         return UrlHelper::cpUrl(
170
-            'enupal-socializer/providers/edit/' . $this->id
170
+            'enupal-socializer/providers/edit/'.$this->id
171 171
         );
172 172
     }
173 173
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         $sources = [
200 200
             [
201 201
                 'key' => '*',
202
-                'label' => Craft::t('enupal-socializer','All Providers'),
202
+                'label' => Craft::t('enupal-socializer', 'All Providers'),
203 203
             ]
204 204
         ];
205 205
 
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
     protected static function defineSortOptions(): array
243 243
     {
244 244
         $attributes = [
245
-            'elements.dateCreated' => Craft::t('enupal-socializer','Date Created'),
246
-            'name' => Craft::t('enupal-socializer','Name')
245
+            'elements.dateCreated' => Craft::t('enupal-socializer', 'Date Created'),
246
+            'name' => Craft::t('enupal-socializer', 'Name')
247 247
         ];
248 248
 
249 249
         return $attributes;
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
     protected static function defineTableAttributes(): array
256 256
     {
257 257
         $attributes = [];
258
-        $attributes['name'] = ['label' => Craft::t('enupal-socializer','Name')];
259
-        $attributes['handle'] = ['label' => Craft::t('enupal-socializer','Handle')];
260
-        $attributes['dateCreated'] = ['label' => Craft::t('enupal-socializer','Date Created')];
258
+        $attributes['name'] = ['label' => Craft::t('enupal-socializer', 'Name')];
259
+        $attributes['handle'] = ['label' => Craft::t('enupal-socializer', 'Handle')];
260
+        $attributes['dateCreated'] = ['label' => Craft::t('enupal-socializer', 'Date Created')];
261 261
 
262 262
         return $attributes;
263 263
     }
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
      */
268 268
     protected static function defineDefaultTableAttributes(string $source): array
269 269
     {
270
-        $attributes = ['name', 'handle' , 'dateCreated'];
270
+        $attributes = ['name', 'handle', 'dateCreated'];
271 271
 
272 272
         return $attributes;
273 273
     }
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
             $record = ProviderRecord::findOne($this->id);
313 313
 
314 314
             if (!$record) {
315
-                throw new \Exception('Invalid Provider ID: ' . $this->id);
315
+                throw new \Exception('Invalid Provider ID: '.$this->id);
316 316
             }
317 317
         } else {
318 318
             $record->id = $this->id;
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
         $record->clientSecret = $this->clientSecret;
327 327
         $record->fieldMapping = $this->fieldMapping;
328 328
 
329
-        if (is_array($record->fieldMapping)){
329
+        if (is_array($record->fieldMapping)) {
330 330
             $record->fieldMapping = json_encode($record->fieldMapping);
331 331
         };
332 332
 
Please login to merge, or discard this patch.
src/elements/db/TokensQuery.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
     {
91 91
         $this->joinElementTable('enupalsocializer_tokens');
92 92
 
93
-        if (is_null($this->query)){
93
+        if (is_null($this->query)) {
94 94
             return false;
95 95
         }
96 96
 
Please login to merge, or discard this patch.
src/elements/db/ProvidersQuery.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@
 block discarded – undo
103 103
     {
104 104
         $this->joinElementTable('enupalsocializer_providers');
105 105
 
106
-        if (is_null($this->query)){
106
+        if (is_null($this->query)) {
107 107
             return false;
108 108
         }
109 109
 
Please login to merge, or discard this patch.
src/elements/Token.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public static function displayName(): string
79 79
     {
80
-        return Craft::t('enupal-socializer','Socializer');
80
+        return Craft::t('enupal-socializer', 'Socializer');
81 81
     }
82 82
 
83 83
     /**
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
             $record = TokenRecord::findOne($this->id);
173 173
 
174 174
             if (!$record) {
175
-                throw new \Exception('Invalid Token ID: ' . $this->id);
175
+                throw new \Exception('Invalid Token ID: '.$this->id);
176 176
             }
177 177
         } else {
178 178
             $record->id = $this->id;
Please login to merge, or discard this patch.
src/services/Providers.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -163,8 +163,8 @@
 block discarded – undo
163 163
         $fieldClass = get_class($field);
164 164
 
165 165
         $supportedClasses = [
166
-          PlainText::class => 1,
167
-          Dropdown::class => 1
166
+            PlainText::class => 1,
167
+            Dropdown::class => 1
168 168
         ];
169 169
 
170 170
         if (isset($supportedClasses[$fieldClass])){
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     public function loginUrl($handle, $options = [])
73 73
     {
74 74
         $provider = $this->getProviderByHandle($handle);
75
-        if (is_null($provider)){
75
+        if (is_null($provider)) {
76 76
             throw new NotSupportedException('Provider not found or disabled: '.$handle);
77 77
         }
78 78
 
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
         ]];
140 140
 
141 141
         foreach ($fields as $field) {
142
-            if (!$this->validateFieldClass($field)){
142
+            if (!$this->validateFieldClass($field)) {
143 143
                 continue;
144 144
             }
145 145
 
146 146
             $option = [
147
-                'label' => $field->name. ' ('.$field->handle.')',
147
+                'label' => $field->name.' ('.$field->handle.')',
148 148
                 'value' => $field->handle
149 149
             ];
150 150
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
           Dropdown::class => 1
168 168
         ];
169 169
 
170
-        if (isset($supportedClasses[$fieldClass])){
170
+        if (isset($supportedClasses[$fieldClass])) {
171 171
             return true;
172 172
         }
173 173
 
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
     {
382 382
         $providers = $this->getAllProviderTypes();
383 383
 
384
-        if ($excludeCreated){
384
+        if ($excludeCreated) {
385 385
             $providers = $this->getExcludeCreatedProviders();
386 386
         }
387 387
 
@@ -576,11 +576,11 @@  discard block
 block discarded – undo
576 576
         $userProfile = $adapter->getUserProfile();
577 577
         $user = Craft::$app->getUser()->getIdentity();
578 578
 
579
-        if (!$user){
579
+        if (!$user) {
580 580
             $user = $this->retrieveUser($userProfile, $provider);
581 581
         }
582 582
 
583
-        if (!$user){
583
+        if (!$user) {
584 584
             Craft::error("Not user to login", __METHOD__);
585 585
             return false;
586 586
         }
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
      */
608 608
     private function retrieveUser(Profile $userProfile, Provider $provider): User
609 609
     {
610
-        if (is_null($userProfile->email)){
610
+        if (is_null($userProfile->email)) {
611 611
             throw new \Exception("Email address is not provided, please check the settings of your application");
612 612
         }
613 613
 
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
         }
619 619
         $settings = Socializer::$app->settings->getSettings();
620 620
 
621
-        if (!$settings->enableUserSignUp){
621
+        if (!$settings->enableUserSignUp) {
622 622
             return null;
623 623
         }
624 624
 
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
         // validate populate
633 633
         $user = $this->populateUserModel($user, $provider, $userProfile);
634 634
 
635
-        if (!Craft::$app->elements->saveElement($user)){
635
+        if (!Craft::$app->elements->saveElement($user)) {
636 636
             Craft::error("Unable to create user: ".json_encode($user->getErrors()));
637 637
             throw new \Exception("Something went wrong while creating the user");
638 638
         }
@@ -661,18 +661,18 @@  discard block
 block discarded – undo
661 661
         }
662 662
 
663 663
         foreach ($fieldMapping as $item) {
664
-            if(isset($item['targetUserField']) && $item['targetUserField']){
664
+            if (isset($item['targetUserField']) && $item['targetUserField']) {
665 665
                 $profileValue = $profile->{$item['sourceFormField']};
666 666
                 $field = $user->getFieldLayout()->getFieldByHandle($item['targetUserField']);
667
-                if ($field){
667
+                if ($field) {
668 668
                     $user->setFieldValue($item['targetUserField'], $profileValue);
669 669
                 }
670 670
             }
671 671
         }
672 672
 
673
-        if ($settings->userGroupId){
673
+        if ($settings->userGroupId) {
674 674
             $userGroup = Craft::$app->getUserGroups()->getGroupById($settings->userGroupId);
675
-            if ($userGroup){
675
+            if ($userGroup) {
676 676
                 Craft::$app->getUsers()->assignUserToGroups($user->id, [$userGroup->id]);
677 677
             }
678 678
         }
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
             $providerRecord = ProviderRecord::findOne($provider->id);
695 695
 
696 696
             if (!$providerRecord) {
697
-                throw new Exception(Craft::t("enupal-socializer",'No Provider exists with the ID “{id}”', ['id' => $provider->id]));
697
+                throw new Exception(Craft::t("enupal-socializer", 'No Provider exists with the ID “{id}”', ['id' => $provider->id]));
698 698
             }
699 699
         }
700 700
 
Please login to merge, or discard this patch.
src/services/Tokens.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         $adapter = $provider->getAdapter();
45 45
         $token = Socializer::$app->tokens->getToken($provider->id, $user->id);
46 46
 
47
-        if (is_null($token)){
47
+        if (is_null($token)) {
48 48
             $token = new Token();
49 49
             $token->providerId = $provider->id;
50 50
             $token->userId = $user->id;
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
     {
69 69
         $user = $user = Craft::$app->getUser()->getIdentity();
70 70
 
71
-        if ($user){
71
+        if ($user) {
72 72
             /** @var Token $token */
73 73
             $token = $this->getToken($providerId, $user->id);
74
-            if ($token){
74
+            if ($token) {
75 75
                 return $token->accessToken;
76 76
             }
77 77
         }
Please login to merge, or discard this patch.
src/controllers/LoginController.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         $redirect = $this->getRedirectUrl();
32 32
 
33 33
         if (is_null($provider)) {
34
-            throw new \Exception(Craft::t('enupal-socializer','Provider not found or disabled'));
34
+            throw new \Exception(Craft::t('enupal-socializer', 'Provider not found or disabled'));
35 35
         }
36 36
 
37 37
         $redirectUrl = $redirect ?? Craft::$app->getRequest()->referrer;
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
         $adapter = $provider->getAdapter();
41 41
 
42 42
         try {
43
-            if ($adapter->authenticate()){
44
-                if (!Socializer::$app->providers->loginOrRegisterUser($provider)){
43
+            if ($adapter->authenticate()) {
44
+                if (!Socializer::$app->providers->loginOrRegisterUser($provider)) {
45 45
                     Craft::$app->getSession()->setError(Craft::t('enupal-socializer', "Unable to authenticate user"));
46 46
                 }
47 47
             }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     {
63 63
         $redirect = Craft::$app->getRequest()->getParam('redirect');
64 64
 
65
-        if ($redirect){
65
+        if ($redirect) {
66 66
             $redirect = UrlHelper::siteUrl($redirect);
67 67
         }
68 68
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         $redirectUrl = Craft::$app->getSession()->get(self::SESSION_REDIRECT_URL);
81 81
         $user = Craft::$app->getUser()->getIdentity();
82 82
 
83
-        if ($user){
83
+        if ($user) {
84 84
             $variables['user'] = $user;
85 85
             $redirectUrl = Craft::$app->getView()->renderString($redirectUrl, $variables);
86 86
         }
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
         $providerHandle = Craft::$app->getSession()->get(self::SESSION_PROVIDER_HANDLE);
104 104
         $provider = Socializer::$app->providers->getProviderByHandle($providerHandle);
105 105
 
106
-        if (is_null($provider)){
107
-            throw new \Exception(Craft::t('enupal-socializer','Provider not found or disabled'));
106
+        if (is_null($provider)) {
107
+            throw new \Exception(Craft::t('enupal-socializer', 'Provider not found or disabled'));
108 108
         }
109 109
 
110
-        if (!Socializer::$app->providers->loginOrRegisterUser($provider)){
110
+        if (!Socializer::$app->providers->loginOrRegisterUser($provider)) {
111 111
             Craft::$app->getSession()->setError(Craft::t('enupal-socializer', "Unable to authenticate user"));
112 112
         }
113 113
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,8 +45,7 @@
 block discarded – undo
45 45
                     Craft::$app->getSession()->setError(Craft::t('enupal-socializer', "Unable to authenticate user"));
46 46
                 }
47 47
             }
48
-        }
49
-        catch (\Exception $e) {
48
+        } catch (\Exception $e) {
50 49
             Craft::error($e->getMessage(), __METHOD__);
51 50
             throw new \Exception($e->getMessage());
52 51
         }
Please login to merge, or discard this patch.
src/controllers/ProvidersController.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
         // Save it
46 46
         if (!Socializer::$app->providers->saveProvider($provider)) {
47
-            Craft::$app->getSession()->setError(Craft::t('enupal-socializer','Couldn’t save provider'));
47
+            Craft::$app->getSession()->setError(Craft::t('enupal-socializer', 'Couldn’t save provider'));
48 48
 
49 49
             Craft::$app->getUrlManager()->setRouteParams([
50 50
                     'provider' => $provider
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             return null;
55 55
         }
56 56
 
57
-        Craft::$app->getSession()->setNotice(Craft::t('enupal-socializer','Provider saved.'));
57
+        Craft::$app->getSession()->setNotice(Craft::t('enupal-socializer', 'Provider saved.'));
58 58
 
59 59
         return $this->redirectToPostedUrl($provider);
60 60
     }
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
             $request = Craft::$app->getRequest();
78 78
             $providerType = $request->getRequiredBodyParam("providerType");
79 79
             $provider = Socializer::$app->providers->getProviderByType($providerType);
80
-            if ($provider){
81
-                throw new \Exception(Craft::t('enupal-socializer','Provider '.$provider->name.' already exists'));
80
+            if ($provider) {
81
+                throw new \Exception(Craft::t('enupal-socializer', 'Provider '.$provider->name.' already exists'));
82 82
             }
83 83
             $providerName = Socializer::$app->providers->getClassNameFromNamespace($providerType);
84 84
             $providerHandle = lcfirst($providerName);
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
                 return $this->redirect($url);
90 90
             } else {
91 91
                 $errors = $provider->getErrors();
92
-                throw new \Exception(Craft::t('enupal-socializer','Error creating the Provider'.json_encode($errors)));
92
+                throw new \Exception(Craft::t('enupal-socializer', 'Error creating the Provider'.json_encode($errors)));
93 93
             }
94 94
         } else {
95 95
             if ($providerId !== null) {
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
                     $provider = Socializer::$app->providers->getProviderById($providerId);
99 99
 
100 100
                     if (!$provider) {
101
-                        throw new NotFoundHttpException(Craft::t('enupal-socializer','Provider not found'));
101
+                        throw new NotFoundHttpException(Craft::t('enupal-socializer', 'Provider not found'));
102 102
                     }
103 103
                 }
104 104
             }
105 105
         }
106 106
 
107
-        if (is_string($provider->fieldMapping)){
107
+        if (is_string($provider->fieldMapping)) {
108 108
             $provider->fieldMapping = json_decode($provider->fieldMapping, true);
109 109
         }
110 110
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
         // @TODO - handle errors
147 147
         Socializer::$app->providers->deleteProvider($provider);
148 148
 
149
-        Craft::$app->getSession()->setNotice(Craft::t('enupal-socializer','Provider deleted.'));
149
+        Craft::$app->getSession()->setNotice(Craft::t('enupal-socializer', 'Provider deleted.'));
150 150
 
151 151
         return $this->redirectToPostedUrl($provider);
152 152
     }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         $reflection = new \ReflectionClass($providerType);
162 162
         $property = $reflection->getProperty('apiDocumentation');
163 163
         $property->setAccessible(true);
164
-        $obj = new $providerType(['callback' => 'https://example.com/path/to/script.php',"keys"=>["key" => "ads", "secret"=>"test"]]);
164
+        $obj = new $providerType(['callback' => 'https://example.com/path/to/script.php', "keys"=>["key" => "ads", "secret"=>"test"]]);
165 165
 
166 166
         return $property->getValue($obj);
167 167
     }
Please login to merge, or discard this patch.
src/controllers/SettingsController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     {
26 26
         $this->requirePostRequest();
27 27
         $settings = Craft::$app->getRequest()->getBodyParam('settings');
28
-        $message = Craft::t('enupal-socializer','Settings saved.');
28
+        $message = Craft::t('enupal-socializer', 'Settings saved.');
29 29
 
30 30
         $plugin = Socializer::$app->settings->getPlugin();
31 31
         $settingsModel = $plugin->getSettings();
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
         if (!Socializer::$app->settings->saveSettings($settingsModel)) {
36 36
 
37
-            Craft::$app->getSession()->setError(Craft::t('enupal-socializer','Couldn’t save settings.'));
37
+            Craft::$app->getSession()->setError(Craft::t('enupal-socializer', 'Couldn’t save settings.'));
38 38
 
39 39
             // Send the settings back to the template
40 40
             Craft::$app->getUrlManager()->setRouteParams([
Please login to merge, or discard this patch.