Passed
Push — develop ( 40cb90...072a02 )
by Andrew
04:51
created
src/controllers/TablesController.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         $siteId = 0
64 64
     ): Response {
65 65
         PermissionHelper::controllerPermissionCheck('retour:dashboard');
66
-        $data = [];
66
+        $data = [ ];
67 67
         $sortField = 'hitCount';
68 68
         $sortType = 'DESC';
69 69
         // Figure out the sorting type
@@ -77,42 +77,42 @@  discard block
 block discarded – undo
77 77
         // Query the db table
78 78
         $offset = ($page - 1) * $per_page;
79 79
         $query = (new Query())
80
-            ->from(['{{%retour_stats}}'])
80
+            ->from([ '{{%retour_stats}}' ])
81 81
             ->offset($offset)
82 82
             ->limit($per_page)
83 83
             ->orderBy("{$sortField} {$sortType}");
84
-        if ((int)$siteId !== 0) {
85
-            $query->where(['siteId' => $siteId]);
84
+        if ((int) $siteId !== 0) {
85
+            $query->where([ 'siteId' => $siteId ]);
86 86
         }
87 87
         if ($filter !== '') {
88
-            $query->where(['like', 'redirectSrcUrl', $filter]);
89
-            $query->orWhere(['like', 'referrerUrl', $filter]);
88
+            $query->where([ 'like', 'redirectSrcUrl', $filter ]);
89
+            $query->orWhere([ 'like', 'referrerUrl', $filter ]);
90 90
         }
91 91
         $stats = $query->all();
92 92
         if ($stats) {
93 93
             // Add in the `addLink` field
94 94
             foreach ($stats as &$stat) {
95
-                $stat['addLink'] = '';
96
-                if (!$stat['handledByRetour']) {
97
-                    $encodedUrl = urlencode('/'.ltrim($stat['redirectSrcUrl'], '/'));
98
-                    $stat['addLink'] = UrlHelper::cpUrl('retour/add-redirect', [
95
+                $stat[ 'addLink' ] = '';
96
+                if (!$stat[ 'handledByRetour' ]) {
97
+                    $encodedUrl = urlencode('/' . ltrim($stat[ 'redirectSrcUrl' ], '/'));
98
+                    $stat[ 'addLink' ] = UrlHelper::cpUrl('retour/add-redirect', [
99 99
                         'defaultUrl' => $encodedUrl
100 100
                     ]);
101 101
                 }
102 102
             }
103 103
             // Format the data for the API
104
-            $data['data'] = $stats;
104
+            $data[ 'data' ] = $stats;
105 105
             $query = (new Query())
106
-                ->from(['{{%retour_stats}}']);
107
-            if ((int)$siteId !== 0) {
108
-                $query->where(['siteId' => $siteId]);
106
+                ->from([ '{{%retour_stats}}' ]);
107
+            if ((int) $siteId !== 0) {
108
+                $query->where([ 'siteId' => $siteId ]);
109 109
             }
110 110
             if ($filter !== '') {
111
-                $query->where(['like', 'redirectSrcUrl', $filter]);
112
-                $query->orWhere(['like', 'referrerUrl', $filter]);
111
+                $query->where([ 'like', 'redirectSrcUrl', $filter ]);
112
+                $query->orWhere([ 'like', 'referrerUrl', $filter ]);
113 113
             }
114 114
             $count = $query->count();
115
-            $data['links']['pagination'] = [
115
+            $data[ 'links' ][ 'pagination' ] = [
116 116
                 'total' => $count,
117 117
                 'per_page' => $per_page,
118 118
                 'current_page' => $page,
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         $siteId = 0
148 148
     ): Response {
149 149
         PermissionHelper::controllerPermissionCheck('retour:redirects');
150
-        $data = [];
150
+        $data = [ ];
151 151
         $sortField = 'hitCount';
152 152
         $sortType = 'DESC';
153 153
         // Figure out the sorting type
@@ -161,52 +161,52 @@  discard block
 block discarded – undo
161 161
         // Query the db table
162 162
         $offset = ($page - 1) * $per_page;
163 163
         $query = (new Query())
164
-            ->from(['{{%retour_static_redirects}}'])
164
+            ->from([ '{{%retour_static_redirects}}' ])
165 165
             ->offset($offset)
166 166
             ->limit($per_page)
167 167
             ->orderBy("{$sortField} {$sortType}");
168
-        if ((int)$siteId !== 0) {
169
-            $query->where(['siteId' => $siteId]);
168
+        if ((int) $siteId !== 0) {
169
+            $query->where([ 'siteId' => $siteId ]);
170 170
         }
171 171
         if ($filter !== '') {
172
-            $query->where(['like', 'redirectSrcUrl', $filter]);
173
-            $query->orWhere(['like', 'redirectDestUrl', $filter]);
172
+            $query->where([ 'like', 'redirectSrcUrl', $filter ]);
173
+            $query->orWhere([ 'like', 'redirectDestUrl', $filter ]);
174 174
         }
175 175
         $redirects = $query->all();
176 176
         // Add in the `deleteLink` field and clean up the redirects
177 177
         foreach ($redirects as &$redirect) {
178 178
             // Make sure the destination URL is not a regex
179
-            if ($redirect['redirectMatchType'] !== 'exactmatch') {
180
-                if (preg_match("/\$\d+/", $redirect['redirectDestUrl'])) {
181
-                    $redirect['redirectDestUrl'] = '';
179
+            if ($redirect[ 'redirectMatchType' ] !== 'exactmatch') {
180
+                if (preg_match("/\$\d+/", $redirect[ 'redirectDestUrl' ])) {
181
+                    $redirect[ 'redirectDestUrl' ] = '';
182 182
                 }
183 183
             }
184 184
             // Handle extracting the site name
185
-            $redirect['siteName'] = Craft::t('retour', 'All Sites');
186
-            if ($redirect['siteId']) {
185
+            $redirect[ 'siteName' ] = Craft::t('retour', 'All Sites');
186
+            if ($redirect[ 'siteId' ]) {
187 187
                 $sites = Craft::$app->getSites();
188
-                $site = $sites->getSiteById($redirect['siteId']);
188
+                $site = $sites->getSiteById($redirect[ 'siteId' ]);
189 189
                 if ($site) {
190
-                    $redirect['siteName'] = $site->name;
190
+                    $redirect[ 'siteName' ] = $site->name;
191 191
                 }
192 192
             }
193 193
 
194
-            $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/'.$redirect['id']);
194
+            $redirect[ 'editLink' ] = UrlHelper::cpUrl('retour/edit-redirect/' . $redirect[ 'id' ]);
195 195
         }
196 196
         // Format the data for the API
197 197
         if ($redirects) {
198
-            $data['data'] = $redirects;
198
+            $data[ 'data' ] = $redirects;
199 199
             $query = (new Query())
200
-                ->from(['{{%retour_static_redirects}}']);
201
-            if ((int)$siteId !== 0) {
202
-                $query->where(['siteId' => $siteId]);
200
+                ->from([ '{{%retour_static_redirects}}' ]);
201
+            if ((int) $siteId !== 0) {
202
+                $query->where([ 'siteId' => $siteId ]);
203 203
             }
204 204
             if ($filter !== '') {
205
-                $query->where(['like', 'redirectSrcUrl', $filter]);
206
-                $query->orWhere(['like', 'redirectDestUrl', $filter]);
205
+                $query->where([ 'like', 'redirectSrcUrl', $filter ]);
206
+                $query->orWhere([ 'like', 'redirectDestUrl', $filter ]);
207 207
             }
208 208
             $count = $query->count();
209
-            $data['links']['pagination'] = [
209
+            $data[ 'links' ][ 'pagination' ] = [
210 210
                 'total' => $count,
211 211
                 'per_page' => $per_page,
212 212
                 'current_page' => $page,
Please login to merge, or discard this patch.
src/controllers/StatisticsController.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     // Protected Properties
41 41
     // =========================================================================
42 42
 
43
-    protected $allowAnonymous = [];
43
+    protected $allowAnonymous = [ ];
44 44
 
45 45
     // Public Methods
46 46
     // =========================================================================
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function actionDashboard(string $siteHandle = null, bool $showWelcome = false): Response
58 58
     {
59
-        $variables = [];
59
+        $variables = [ ];
60 60
         PermissionHelper::controllerPermissionCheck('retour:dashboard');
61 61
         // Trim the statistics
62 62
         Retour::$plugin->statistics->trimStatistics();
@@ -71,34 +71,34 @@  discard block
 block discarded – undo
71 71
         } catch (InvalidConfigException $e) {
72 72
             Craft::error($e->getMessage(), __METHOD__);
73 73
         }
74
-        $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl(
74
+        $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl(
75 75
             '@nystudio107/retour/assetbundles/retour/dist',
76 76
             true
77 77
         );
78 78
         // Enabled sites
79 79
         MultiSiteHelper::setMultiSiteVariables($siteHandle, $siteId, $variables);
80
-        $variables['controllerHandle'] = 'dashboard';
80
+        $variables[ 'controllerHandle' ] = 'dashboard';
81 81
 
82 82
         // Basic variables
83
-        $variables['fullPageForm'] = false;
84
-        $variables['docsUrl'] = self::DOCUMENTATION_URL;
85
-        $variables['pluginName'] = $pluginName;
86
-        $variables['title'] = $templateTitle;
87
-        $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : '';
88
-        $variables['crumbs'] = [
83
+        $variables[ 'fullPageForm' ] = false;
84
+        $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL;
85
+        $variables[ 'pluginName' ] = $pluginName;
86
+        $variables[ 'title' ] = $templateTitle;
87
+        $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : '';
88
+        $variables[ 'crumbs' ] = [
89 89
             [
90 90
                 'label' => $pluginName,
91 91
                 'url' => UrlHelper::cpUrl('retour'),
92 92
             ],
93 93
             [
94 94
                 'label' => $templateTitle,
95
-                'url' => UrlHelper::cpUrl('retour/dashboard'.$siteHandleUri),
95
+                'url' => UrlHelper::cpUrl('retour/dashboard' . $siteHandleUri),
96 96
             ],
97 97
         ];
98
-        $variables['docTitle'] = "{$pluginName} - {$templateTitle}";
99
-        $variables['selectedSubnavItem'] = 'dashboard';
100
-        $variables['showWelcome'] = $showWelcome;
101
-        $variables['settings'] = Retour::$settings;
98
+        $variables[ 'docTitle' ] = "{$pluginName} - {$templateTitle}";
99
+        $variables[ 'selectedSubnavItem' ] = 'dashboard';
100
+        $variables[ 'showWelcome' ] = $showWelcome;
101
+        $variables[ 'settings' ] = Retour::$settings;
102 102
 
103 103
         // Render the template
104 104
         return $this->renderTemplate('retour/dashboard/index', $variables);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
             Craft::t(
117 117
                 'retour',
118 118
                 'Retour statistics cleared: {error}',
119
-                ['error' => $error]
119
+                [ 'error' => $error ]
120 120
             ),
121 121
             __METHOD__
122 122
         );
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
             Craft::t(
150 150
                 'retour',
151 151
                 'Retour statistics deleted: {error}',
152
-                ['error' => $stickyError]
152
+                [ 'error' => $stickyError ]
153 153
             ),
154 154
             __METHOD__
155 155
         );
Please login to merge, or discard this patch.