Passed
Push — v3 ( dc9fae...2f2fc6 )
by Andrew
18:54 queued 11:52
created
src/helpers/MultiSite.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     public static function setSitesMenuVariables(array &$variables)
37 37
     {
38 38
         // Set defaults based on the section settings
39
-        $variables['sitesMenu'] = [
39
+        $variables[ 'sitesMenu' ] = [
40 40
             0 => Craft::t(
41 41
                 'retour',
42 42
                 'All Sites'
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
             /** @var Site $site */
50 50
             foreach ($sites->getAllGroups() as $group) {
51 51
                 $groupSites = $sites->getSitesByGroupId($group->id);
52
-                $variables['sitesMenu'][$group->name]
53
-                    = ['optgroup' => $group->name];
52
+                $variables[ 'sitesMenu' ][ $group->name ]
53
+                    = [ 'optgroup' => $group->name ];
54 54
                 foreach ($groupSites as $groupSite) {
55 55
                     if (in_array($groupSite->id, $editableSites, false)) {
56
-                        $variables['sitesMenu'][$groupSite->id] = $groupSite->name;
56
+                        $variables[ 'sitesMenu' ][ $groupSite->id ] = $groupSite->name;
57 57
                     }
58 58
                 }
59 59
             }
@@ -73,53 +73,53 @@  discard block
 block discarded – undo
73 73
         $sites = Craft::$app->getSites();
74 74
         if (Craft::$app->getIsMultiSite()) {
75 75
             // Set defaults based on the section settings
76
-            $variables['enabledSiteIds'] = [];
77
-            $variables['siteIds'] = [];
76
+            $variables[ 'enabledSiteIds' ] = [ ];
77
+            $variables[ 'siteIds' ] = [ ];
78 78
 
79 79
             /** @var Site $site */
80 80
             foreach ($sites->getEditableSiteIds() as $editableSiteId) {
81
-                $variables['enabledSiteIds'][] = $editableSiteId;
82
-                $variables['siteIds'][] = $editableSiteId;
81
+                $variables[ 'enabledSiteIds' ][ ] = $editableSiteId;
82
+                $variables[ 'siteIds' ][ ] = $editableSiteId;
83 83
             }
84 84
 
85 85
             // Make sure the $siteId they are trying to edit is in our array of editable sites
86
-            if (!\in_array($siteId, $variables['enabledSiteIds'], false)) {
87
-                if (!empty($variables['enabledSiteIds'])) {
86
+            if (!\in_array($siteId, $variables[ 'enabledSiteIds' ], false)) {
87
+                if (!empty($variables[ 'enabledSiteIds' ])) {
88 88
                     if ($siteId !== 0) {
89
-                        $siteId = reset($variables['enabledSiteIds']);
89
+                        $siteId = reset($variables[ 'enabledSiteIds' ]);
90 90
                     }
91 91
                 } else {
92
-                    self::requirePermission('editSite:'.$siteId);
92
+                    self::requirePermission('editSite:' . $siteId);
93 93
                 }
94 94
             }
95 95
         }
96 96
         // Set the currentSiteId and currentSiteHandle
97
-        $variables['currentSiteId'] = empty($siteId) ? 0 : $siteId;
98
-        $variables['currentSiteHandle'] = empty($siteHandle)
97
+        $variables[ 'currentSiteId' ] = empty($siteId) ? 0 : $siteId;
98
+        $variables[ 'currentSiteHandle' ] = empty($siteHandle)
99 99
             ? Craft::$app->getSites()->currentSite->handle
100 100
             : $siteHandle;
101 101
 
102 102
         // Page title
103
-        $variables['showSites'] = (
103
+        $variables[ 'showSites' ] = (
104 104
             Craft::$app->getIsMultiSite() &&
105
-            \count($variables['enabledSiteIds'])
105
+            \count($variables[ 'enabledSiteIds' ])
106 106
         );
107 107
 
108
-        if ($variables['showSites']) {
109
-            if ($variables['currentSiteId'] === 0) {
110
-                $variables['sitesMenuLabel'] = Craft::t(
108
+        if ($variables[ 'showSites' ]) {
109
+            if ($variables[ 'currentSiteId' ] === 0) {
110
+                $variables[ 'sitesMenuLabel' ] = Craft::t(
111 111
                     'retour',
112 112
                     'All Sites'
113 113
                 );
114 114
             } else {
115
-                $variables['sitesMenuLabel'] = Craft::t(
115
+                $variables[ 'sitesMenuLabel' ] = Craft::t(
116 116
                     'site',
117
-                    $sites->getSiteById((int)$variables['currentSiteId'])->name
117
+                    $sites->getSiteById((int) $variables[ 'currentSiteId' ])->name
118 118
                 );
119 119
             }
120 120
         } else {
121
-            $variables['currentSiteId'] = 0;
122
-            $variables['sitesMenuLabel'] = '';
121
+            $variables[ 'currentSiteId' ] = 0;
122
+            $variables[ 'sitesMenuLabel' ] = '';
123 123
         }
124 124
     }
125 125
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
         if ($siteHandle !== null) {
138 138
             $site = Craft::$app->getSites()->getSiteByHandle($siteHandle);
139 139
             if (!$site) {
140
-                throw new NotFoundHttpException('Invalid site handle: '.$siteHandle);
140
+                throw new NotFoundHttpException('Invalid site handle: ' . $siteHandle);
141 141
             }
142 142
             $siteId = $site->id;
143 143
         } else {
Please login to merge, or discard this patch.
src/migrations/m190416_212500_widget_type_update.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
         // Update retour widget type
21 21
         $this->update('{{%widgets}}', [
22 22
             'type' => RetourWidget::class
23
-        ], ['type' => 'Retour']);
23
+        ], [ 'type' => 'Retour' ]);
24 24
 
25 25
         return true;
26 26
     }
Please login to merge, or discard this patch.
src/migrations/Install.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
         // Update retour widget type
21 21
         $this->update('{{%widgets}}', [
22 22
             'type' => RetourWidget::class
23
-        ], ['type' => 'Retour']);
23
+        ], [ 'type' => 'Retour' ]);
24 24
 
25 25
         return true;
26 26
     }
Please login to merge, or discard this patch.
src/services/Statistics.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         }
61 61
         // Query the db table
62 62
         $stats = (new Query())
63
-            ->from(['{{%retour_stats}}'])
63
+            ->from([ '{{%retour_stats}}' ])
64 64
             ->orderBy('hitCount DESC')
65 65
             ->limit(Retour::$settings->statsDisplayLimit)
66 66
             ->all();
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
     public function getRecentStatistics($days = 1, $handled = false): array
80 80
     {
81 81
         // Ensure is an int
82
-        $handledInt = (int)$handled;
83
-        $stats = [];
82
+        $handledInt = (int) $handled;
83
+        $stats = [ ];
84 84
         $db = Craft::$app->getDb();
85 85
         if ($db->getIsMysql()) {
86 86
             // Query the db table
87 87
             $stats = (new Query())
88
-                ->from(['{{%retour_stats}}'])
88
+                ->from([ '{{%retour_stats}}' ])
89 89
                 ->where("hitLastTime >= ( CURDATE() - INTERVAL '{$days}' DAY )")
90 90
                 ->andWhere("handledByRetour = {$handledInt}")
91 91
                 ->orderBy('hitLastTime DESC')
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
         if ($db->getIsPgsql()) {
95 95
             // Query the db table
96 96
             $stats = (new Query())
97
-                ->from(['{{%retour_stats}}'])
97
+                ->from([ '{{%retour_stats}}' ])
98 98
                 ->where("\"hitLastTime\" >= ( CURRENT_TIMESTAMP - INTERVAL '{$days} days' )")
99
-                ->andWhere(['handledByRetour' => $handledInt])
99
+                ->andWhere([ 'handledByRetour' => $handledInt ])
100 100
                 ->orderBy('hitLastTime DESC')
101 101
                 ->all();
102 102
         }
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
         $stats->validate();
164 164
         // Find any existing retour_stats record
165 165
         $statsConfig = (new Query())
166
-            ->from(['{{%retour_stats}}'])
167
-            ->where(['redirectSrcUrl' => $stats->redirectSrcUrl])
166
+            ->from([ '{{%retour_stats}}' ])
167
+            ->where([ 'redirectSrcUrl' => $stats->redirectSrcUrl ])
168 168
             ->one();
169 169
         // If no record is found, initialize some values
170 170
         if ($statsConfig === null) {
171 171
             $stats->id = 0;
172 172
             $stats->hitCount = 0;
173 173
         } else {
174
-            $stats->id = $statsConfig['id'];
175
-            $stats->hitCount = $statsConfig['hitCount'];
174
+            $stats->id = $statsConfig[ 'id' ];
175
+            $stats->hitCount = $statsConfig[ 'hitCount' ];
176 176
         }
177 177
         // Merge in the updated info
178 178
         $stats->siteId = $siteId;
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
         $stats->userAgent = $userAgent;
182 182
         $stats->exceptionMessage = $exceptionMessage;
183 183
         $stats->exceptionFilePath = $exceptionFilePath;
184
-        $stats->exceptionFileLine = (int)$exceptionFileLine;
184
+        $stats->exceptionFileLine = (int) $exceptionFileLine;
185 185
         $stats->hitLastTime = Db::prepareDateForDb(new \DateTime());
186
-        $stats->handledByRetour = (int)$handled;
186
+        $stats->handledByRetour = (int) $handled;
187 187
         $stats->hitCount++;
188 188
         $statsConfig = $stats->getAttributes();
189 189
         // Record the updated statistics
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
                 Craft::t(
254 254
                     'retour',
255 255
                     'Trimmed {rows} from retour_stats table',
256
-                    ['rows' => $affectedRows]
256
+                    [ 'rows' => $affectedRows ]
257 257
                 ),
258 258
                 __METHOD__
259 259
             );
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
                 Craft::t(
275 275
                     'retour',
276 276
                     'Error validating statistics {id}: {errors}',
277
-                    ['id' => $stats->id, 'errors' => print_r($stats->getErrors(), true)]
277
+                    [ 'id' => $stats->id, 'errors' => print_r($stats->getErrors(), true) ]
278 278
                 ),
279 279
                 __METHOD__
280 280
             );
@@ -284,14 +284,14 @@  discard block
 block discarded – undo
284 284
         // Get the validated model attributes and save them to the db
285 285
         $statsConfig = $stats->getAttributes();
286 286
         $db = Craft::$app->getDb();
287
-        if ($statsConfig['id'] !== 0) {
287
+        if ($statsConfig[ 'id' ] !== 0) {
288 288
             // Update the existing record
289 289
             try {
290 290
                 $result = $db->createCommand()->update(
291 291
                     '{{%retour_stats}}',
292 292
                     $statsConfig,
293 293
                     [
294
-                        'id' => $statsConfig['id'],
294
+                        'id' => $statsConfig[ 'id' ],
295 295
                     ]
296 296
                 )->execute();
297 297
             } catch (Exception $e) {
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
                 // Craft::error($e->getMessage(), __METHOD__);
301 301
             }
302 302
         } else {
303
-            unset($statsConfig['id']);
303
+            unset($statsConfig[ 'id' ]);
304 304
             // Create a new record
305 305
             try {
306 306
                 $db->createCommand()->insert(
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
         $now = round(microtime(true) * 1000);
328 328
         $cache = Craft::$app->getCache();
329 329
         $then = $cache->get(self::LAST_STATISTICS_TRIM_CACHE_KEY);
330
-        if (($then !== false) && ($now - (int)$then < Retour::$settings->statisticsRateLimitMs)) {
330
+        if (($then !== false) && ($now - (int) $then < Retour::$settings->statisticsRateLimitMs)) {
331 331
             $limited = true;
332 332
         }
333 333
         $cache->set(self::LAST_STATISTICS_TRIM_CACHE_KEY, $now, 0);
Please login to merge, or discard this patch.
src/listeners/GetCraftQLSchema.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -62,36 +62,36 @@  discard block
 block discarded – undo
62 62
                 // Boolean field
63 63
                 $retourField
64 64
                     ->addBooleanField($field)
65
-                    ->resolve(function ($redirect) use ($field) {
66
-                        $result = $redirect[$field] ?? null;
67
-                        return $result === null ? $result : (bool)$result;
65
+                    ->resolve(function($redirect) use ($field) {
66
+                        $result = $redirect[ $field ] ?? null;
67
+                        return $result === null ? $result : (bool) $result;
68 68
                     });
69 69
             } elseif (in_array($field, self::INT_FIELDS, true)) {
70 70
                 // Integer field
71 71
                 $retourField
72 72
                     ->addIntField($field)
73
-                    ->resolve(function ($redirect) use ($field) {
74
-                        $result = $redirect[$field] ?? null;
75
-                        return $result === null ? $result : (int)$result;
73
+                    ->resolve(function($redirect) use ($field) {
74
+                        $result = $redirect[ $field ] ?? null;
75
+                        return $result === null ? $result : (int) $result;
76 76
                     });
77 77
             } else {
78 78
                 // String field
79 79
                 $retourField
80 80
                     ->addStringField($field)
81
-                    ->resolve(function ($redirect) use ($field) {
82
-                        $result = $redirect[$field] ?? null;
83
-                        return $result === null ? $result : (string)$result;
81
+                    ->resolve(function($redirect) use ($field) {
82
+                        $result = $redirect[ $field ] ?? null;
83
+                        return $result === null ? $result : (string) $result;
84 84
                     });
85 85
             }
86 86
         }
87 87
         // Add the root
88 88
         $event->schema->addField('retour')
89
-            ->arguments(function (FieldBuilder $field) {
89
+            ->arguments(function(FieldBuilder $field) {
90 90
                 $field->addStringArgument('uri');
91 91
                 $field->addIntArgument('siteId');
92 92
             })
93 93
             ->type($retourField)
94
-            ->resolve(function ($root, $args, $context, $info) {
94
+            ->resolve(function($root, $args, $context, $info) {
95 95
                 // If our root is an Element, extract the URI and siteId from it
96 96
                 if ($root instanceof Element) {
97 97
                     /** Element $root */
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
                     $siteId = $root->siteId;
100 100
                 } else {
101 101
                     // Otherwise use the passed in arguments, or defaults
102
-                    $uri = $args['uri'] ?? '/';
103
-                    $siteId = $args['siteId'] ?? null;
102
+                    $uri = $args[ 'uri' ] ?? '/';
103
+                    $siteId = $args[ 'siteId' ] ?? null;
104 104
                 }
105 105
                 $uri = trim($uri === '/' ? '__home__' : $uri);
106 106
 
Please login to merge, or discard this patch.
src/gql/types/RetourType.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
      */
32 32
     public function __construct(array $config)
33 33
     {
34
-        $config['interfaces'] = [
34
+        $config[ 'interfaces' ] = [
35 35
             RetourInterface::getType(),
36 36
         ];
37 37
 
@@ -45,6 +45,6 @@  discard block
 block discarded – undo
45 45
     {
46 46
         $fieldName = $resolveInfo->fieldName;
47 47
 
48
-        return $source[$fieldName];
48
+        return $source[ $fieldName ];
49 49
     }
50 50
 }
Please login to merge, or discard this patch.
src/gql/resolvers/RetourResolver.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,8 +40,8 @@
 block discarded – undo
40 40
             $siteId = $source->siteId;
41 41
         } else {
42 42
             // Otherwise use the passed in arguments, or defaults
43
-            $uri = $arguments['uri'] ?? '/';
44
-            $siteId = $arguments['siteId'] ?? null;
43
+            $uri = $arguments[ 'uri' ] ?? '/';
44
+            $siteId = $arguments[ 'siteId' ] ?? null;
45 45
         }
46 46
         $uri = trim($uri === '/' ? '__home__' : $uri);
47 47
 
Please login to merge, or discard this patch.
src/gql/interfaces/RetourInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,9 +48,9 @@
 block discarded – undo
48 48
 
49 49
         $type = GqlEntityRegistry::createEntity(self::class, new InterfaceType([
50 50
             'name' => static::getName(),
51
-            'fields' => self::class.'::getFieldDefinitions',
51
+            'fields' => self::class . '::getFieldDefinitions',
52 52
             'description' => 'This is the interface implemented by Retour.',
53
-            'resolveType' => function (array $value) {
53
+            'resolveType' => function(array $value) {
54 54
                 return GqlEntityRegistry::getEntity(RetourGenerator::getName());
55 55
             },
56 56
         ]));
Please login to merge, or discard this patch.
src/gql/types/generators/RetourGenerator.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,24 +34,24 @@
 block discarded – undo
34 34
      */
35 35
     public static function generateTypes($context = null): array
36 36
     {
37
-        $gqlTypes = [];
37
+        $gqlTypes = [ ];
38 38
         $retourFields = RetourInterface::getFieldDefinitions();
39 39
         $retourArgs = RetourArguments::getArguments();
40 40
         $typeName = self::getName();
41 41
         $retourType = GqlEntityRegistry::getEntity($typeName)
42 42
             ?: GqlEntityRegistry::createEntity($typeName, new RetourType([
43 43
                 'name' => $typeName,
44
-                'args' => function () use ($retourArgs) {
44
+                'args' => function() use ($retourArgs) {
45 45
                     return $retourArgs;
46 46
                 },
47
-                'fields' => function () use ($retourFields) {
47
+                'fields' => function() use ($retourFields) {
48 48
                     return $retourFields;
49 49
                 },
50 50
                 'description' => 'This entity has all the Retour fields',
51 51
             ]));
52 52
 
53
-        $gqlTypes[$typeName] = $retourType;
54
-        TypeLoader::registerType($typeName, function () use ($retourType) {
53
+        $gqlTypes[ $typeName ] = $retourType;
54
+        TypeLoader::registerType($typeName, function() use ($retourType) {
55 55
             return $retourType;
56 56
         });
57 57
 
Please login to merge, or discard this patch.