@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | { |
37 | 37 | foreach ($config as $propName => $propValue) { |
38 | 38 | if (!property_exists($class, $propName)) { |
39 | - unset($config[$propName]); |
|
39 | + unset($config[ $propName ]); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | /** |
48 | 48 | * @inheritdoc |
49 | 49 | */ |
50 | - public function __construct(array $config = []) |
|
50 | + public function __construct(array $config = [ ]) |
|
51 | 51 | { |
52 | 52 | // Unset any deprecated properties |
53 | 53 | self::cleanProperties(static::class, $config); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | if (!empty($string)) { |
45 | 45 | $string = strip_tags($string); |
46 | - $result = (string)Stringy::create($string)->truncate($length, $substring); |
|
46 | + $result = (string) Stringy::create($string)->truncate($length, $substring); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | return $result; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | if (!empty($string)) { |
69 | 69 | $string = strip_tags($string); |
70 | - $result = (string)Stringy::create($string)->safeTruncate($length, $substring); |
|
70 | + $result = (string) Stringy::create($string)->safeTruncate($length, $substring); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | return $result; |
@@ -78,8 +78,8 @@ |
||
78 | 78 | $rules = array_merge( |
79 | 79 | $rules, |
80 | 80 | [ |
81 | - ['numberOfDays', 'integer', 'min' => 1], |
|
82 | - ['numberOfDays', 'default', 'value' => 30], |
|
81 | + [ 'numberOfDays', 'integer', 'min' => 1 ], |
|
82 | + [ 'numberOfDays', 'default', 'value' => 30 ], |
|
83 | 83 | ] |
84 | 84 | ); |
85 | 85 | return $rules; |
@@ -59,7 +59,7 @@ |
||
59 | 59 | return; |
60 | 60 | } |
61 | 61 | // Make sure there is a leading / |
62 | - $value = '/'.ltrim($value, '/'); |
|
62 | + $value = '/' . ltrim($value, '/'); |
|
63 | 63 | $model->$attribute = $value; |
64 | 64 | } |
65 | 65 | } |
@@ -66,13 +66,13 @@ |
||
66 | 66 | */ |
67 | 67 | public function actionTrim(): int |
68 | 68 | { |
69 | - echo Craft::t('retour', 'Trimming statistics').PHP_EOL; |
|
69 | + echo Craft::t('retour', 'Trimming statistics') . PHP_EOL; |
|
70 | 70 | $affectedRows = Retour::$plugin->statistics->trimStatistics($this->limit); |
71 | 71 | echo Craft::t( |
72 | 72 | 'retour', |
73 | 73 | 'Trimmed {rows} from retour_stats table', |
74 | - ['rows' => $affectedRows] |
|
75 | - ).PHP_EOL; |
|
74 | + [ 'rows' => $affectedRows ] |
|
75 | + ) . PHP_EOL; |
|
76 | 76 | |
77 | 77 | return 0; |
78 | 78 | } |
@@ -96,18 +96,18 @@ discard block |
||
96 | 96 | public function rules() |
97 | 97 | { |
98 | 98 | return [ |
99 | - ['id', 'integer'], |
|
100 | - ['siteId', 'integer'], |
|
101 | - ['siteId', 'default', 'value' => null], |
|
102 | - ['associatedElementId', 'default', 'value' => 0], |
|
103 | - ['associatedElementId', 'integer'], |
|
104 | - ['enabled', 'boolean'], |
|
105 | - ['redirectSrcMatch', 'default', 'value' => 'pathonly'], |
|
106 | - ['redirectSrcMatch', DbStringValidator::class, 'max' => 32], |
|
107 | - ['redirectSrcMatch', 'string'], |
|
108 | - ['redirectMatchType', 'default', 'value' => 'exactmatch'], |
|
109 | - ['redirectMatchType', DbStringValidator::class, 'max' => 32], |
|
110 | - ['redirectMatchType', 'string'], |
|
99 | + [ 'id', 'integer' ], |
|
100 | + [ 'siteId', 'integer' ], |
|
101 | + [ 'siteId', 'default', 'value' => null ], |
|
102 | + [ 'associatedElementId', 'default', 'value' => 0 ], |
|
103 | + [ 'associatedElementId', 'integer' ], |
|
104 | + [ 'enabled', 'boolean' ], |
|
105 | + [ 'redirectSrcMatch', 'default', 'value' => 'pathonly' ], |
|
106 | + [ 'redirectSrcMatch', DbStringValidator::class, 'max' => 32 ], |
|
107 | + [ 'redirectSrcMatch', 'string' ], |
|
108 | + [ 'redirectMatchType', 'default', 'value' => 'exactmatch' ], |
|
109 | + [ 'redirectMatchType', DbStringValidator::class, 'max' => 32 ], |
|
110 | + [ 'redirectMatchType', 'string' ], |
|
111 | 111 | [ |
112 | 112 | [ |
113 | 113 | 'redirectSrcUrl', |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | 'default', |
118 | 118 | 'value' => '' |
119 | 119 | ], |
120 | - ['redirectSrcUrlParsed', ParsedUriValidator::class, 'source' => 'redirectSrcUrl'], |
|
120 | + [ 'redirectSrcUrlParsed', ParsedUriValidator::class, 'source' => 'redirectSrcUrl' ], |
|
121 | 121 | [ |
122 | 122 | [ |
123 | 123 | 'redirectSrcUrl', |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | ], |
145 | 145 | 'string' |
146 | 146 | ], |
147 | - ['redirectHttpCode', 'integer'], |
|
148 | - ['redirectHttpCode', 'default', 'value' => 301], |
|
149 | - ['hitCount', 'default', 'value' => 0], |
|
150 | - ['hitCount', 'integer'], |
|
151 | - ['hitLastTime', 'safe'], |
|
147 | + [ 'redirectHttpCode', 'integer' ], |
|
148 | + [ 'redirectHttpCode', 'default', 'value' => 301 ], |
|
149 | + [ 'hitCount', 'default', 'value' => 0 ], |
|
150 | + [ 'hitCount', 'integer' ], |
|
151 | + [ 'hitLastTime', 'safe' ], |
|
152 | 152 | ]; |
153 | 153 | } |
154 | 154 |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | public function rules() |
95 | 95 | { |
96 | 96 | return [ |
97 | - ['id', 'integer'], |
|
98 | - ['siteId', 'integer'], |
|
99 | - ['siteId', 'default', 'value' => null], |
|
97 | + [ 'id', 'integer' ], |
|
98 | + [ 'siteId', 'integer' ], |
|
99 | + [ 'siteId', 'default', 'value' => null ], |
|
100 | 100 | [ |
101 | 101 | [ |
102 | 102 | 'redirectSrcUrl', |
@@ -126,19 +126,19 @@ discard block |
||
126 | 126 | 'default', |
127 | 127 | 'value' => '' |
128 | 128 | ], |
129 | - ['exceptionFileLine', 'integer'], |
|
130 | - ['exceptionFileLine', 'default', 'value' => 0], |
|
131 | - ['referrerUrl', DbStringValidator::class, 'max' => 2000], |
|
132 | - ['referrerUrl', 'string'], |
|
133 | - ['referrerUrl', 'default', 'value' => ''], |
|
134 | - ['remoteIp', DbStringValidator::class, 'max' => 45], |
|
135 | - ['remoteIp', 'string'], |
|
136 | - ['remoteIp', 'default', 'value' => ''], |
|
137 | - ['hitCount', 'integer'], |
|
138 | - ['hitCount', 'default', 'value' => 0], |
|
139 | - ['hitLastTime', 'safe'], |
|
140 | - ['handledByRetour', 'integer', 'min' => 0, 'max' => 1], |
|
141 | - ['handledByRetour', 'default', 'value' => 0], |
|
129 | + [ 'exceptionFileLine', 'integer' ], |
|
130 | + [ 'exceptionFileLine', 'default', 'value' => 0 ], |
|
131 | + [ 'referrerUrl', DbStringValidator::class, 'max' => 2000 ], |
|
132 | + [ 'referrerUrl', 'string' ], |
|
133 | + [ 'referrerUrl', 'default', 'value' => '' ], |
|
134 | + [ 'remoteIp', DbStringValidator::class, 'max' => 45 ], |
|
135 | + [ 'remoteIp', 'string' ], |
|
136 | + [ 'remoteIp', 'default', 'value' => '' ], |
|
137 | + [ 'hitCount', 'integer' ], |
|
138 | + [ 'hitCount', 'default', 'value' => 0 ], |
|
139 | + [ 'hitLastTime', 'safe' ], |
|
140 | + [ 'handledByRetour', 'integer', 'min' => 0, 'max' => 1 ], |
|
141 | + [ 'handledByRetour', 'default', 'value' => 0 ], |
|
142 | 142 | ]; |
143 | 143 | } |
144 | 144 |
@@ -96,18 +96,18 @@ discard block |
||
96 | 96 | public function rules() |
97 | 97 | { |
98 | 98 | return [ |
99 | - ['id', 'integer'], |
|
100 | - ['siteId', 'integer'], |
|
101 | - ['siteId', 'default', 'value' => null], |
|
102 | - ['associatedElementId', 'default', 'value' => 0], |
|
103 | - ['associatedElementId', 'integer'], |
|
104 | - ['enabled', 'boolean'], |
|
105 | - ['redirectSrcMatch', 'default', 'value' => 'pathonly'], |
|
106 | - ['redirectSrcMatch', DbStringValidator::class, 'max' => 32], |
|
107 | - ['redirectSrcMatch', 'string'], |
|
108 | - ['redirectMatchType', 'default', 'value' => 'exactmatch'], |
|
109 | - ['redirectMatchType', DbStringValidator::class, 'max' => 32], |
|
110 | - ['redirectMatchType', 'string'], |
|
99 | + [ 'id', 'integer' ], |
|
100 | + [ 'siteId', 'integer' ], |
|
101 | + [ 'siteId', 'default', 'value' => null ], |
|
102 | + [ 'associatedElementId', 'default', 'value' => 0 ], |
|
103 | + [ 'associatedElementId', 'integer' ], |
|
104 | + [ 'enabled', 'boolean' ], |
|
105 | + [ 'redirectSrcMatch', 'default', 'value' => 'pathonly' ], |
|
106 | + [ 'redirectSrcMatch', DbStringValidator::class, 'max' => 32 ], |
|
107 | + [ 'redirectSrcMatch', 'string' ], |
|
108 | + [ 'redirectMatchType', 'default', 'value' => 'exactmatch' ], |
|
109 | + [ 'redirectMatchType', DbStringValidator::class, 'max' => 32 ], |
|
110 | + [ 'redirectMatchType', 'string' ], |
|
111 | 111 | [ |
112 | 112 | [ |
113 | 113 | 'redirectSrcUrl', |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | 'default', |
118 | 118 | 'value' => '' |
119 | 119 | ], |
120 | - ['redirectSrcUrlParsed', ParsedUriValidator::class, 'source' => 'redirectSrcUrl'], |
|
120 | + [ 'redirectSrcUrlParsed', ParsedUriValidator::class, 'source' => 'redirectSrcUrl' ], |
|
121 | 121 | [ |
122 | 122 | [ |
123 | 123 | 'redirectSrcUrl', |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | ], |
145 | 145 | 'string' |
146 | 146 | ], |
147 | - ['redirectHttpCode', 'integer'], |
|
148 | - ['redirectHttpCode', 'default', 'value' => 301], |
|
149 | - ['hitCount', 'default', 'value' => 0], |
|
150 | - ['hitCount', 'integer'], |
|
151 | - ['hitLastTime', 'safe'], |
|
147 | + [ 'redirectHttpCode', 'integer' ], |
|
148 | + [ 'redirectHttpCode', 'default', 'value' => 301 ], |
|
149 | + [ 'hitCount', 'default', 'value' => 0 ], |
|
150 | + [ 'hitCount', 'integer' ], |
|
151 | + [ 'hitLastTime', 'safe' ], |
|
152 | 152 | ]; |
153 | 153 | } |
154 | 154 |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | public function actionDashboard(string $range = 'day', int $siteId = 0): Response |
56 | 56 | { |
57 | 57 | PermissionHelper::controllerPermissionCheck('retour:dashboard'); |
58 | - $data = []; |
|
58 | + $data = [ ]; |
|
59 | 59 | $days = 1; |
60 | 60 | switch ($range) { |
61 | 61 | case 'day': |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | 'COUNT(handledByRetour = 1 or null) as handled_cnt', |
82 | 82 | ]) |
83 | 83 | ->where("hitLastTime >= ( CURDATE() - INTERVAL '{$days}' DAY )"); |
84 | - if ((int)$siteId !== 0) { |
|
85 | - $query->andWhere(['siteId' => $siteId]); |
|
84 | + if ((int) $siteId !== 0) { |
|
85 | + $query->andWhere([ 'siteId' => $siteId ]); |
|
86 | 86 | } |
87 | 87 | $query |
88 | 88 | ->orderBy('date_formatted ASC') |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | "COUNT(CASE WHEN \"handledByRetour\" = true THEN 1 END) as handled_cnt", |
100 | 100 | ]) |
101 | 101 | ->where("\"hitLastTime\" >= ( CURRENT_TIMESTAMP - INTERVAL '{$days} days' )"); |
102 | - if ((int)$siteId !== 0) { |
|
103 | - $query->andWhere(['siteId' => $siteId]); |
|
102 | + if ((int) $siteId !== 0) { |
|
103 | + $query->andWhere([ 'siteId' => $siteId ]); |
|
104 | 104 | } |
105 | 105 | $query |
106 | 106 | ->orderBy('date_formatted ASC') |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | $stats = $query->all(); |
109 | 109 | } |
110 | 110 | if ($stats) { |
111 | - $data[] = [ |
|
111 | + $data[ ] = [ |
|
112 | 112 | 'name' => '404 hits', |
113 | - 'data' => array_merge(['0'], ArrayHelper::getColumn($stats, 'cnt')), |
|
114 | - 'labels' => array_merge(['-'], ArrayHelper::getColumn($stats, 'date_formatted')), |
|
113 | + 'data' => array_merge([ '0' ], ArrayHelper::getColumn($stats, 'cnt')), |
|
114 | + 'labels' => array_merge([ '-' ], ArrayHelper::getColumn($stats, 'date_formatted')), |
|
115 | 115 | ]; |
116 | - $data[] = [ |
|
116 | + $data[ ] = [ |
|
117 | 117 | 'name' => 'Handled 404 hits', |
118 | - 'data' => array_merge(['0'], ArrayHelper::getColumn($stats, 'handled_cnt')), |
|
119 | - 'labels' => array_merge(['-'], ArrayHelper::getColumn($stats, 'date_formatted')), |
|
118 | + 'data' => array_merge([ '0' ], ArrayHelper::getColumn($stats, 'handled_cnt')), |
|
119 | + 'labels' => array_merge([ '-' ], ArrayHelper::getColumn($stats, 'date_formatted')), |
|
120 | 120 | ]; |
121 | 121 | } |
122 | 122 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function actionWidget($days = 1): Response |
134 | 134 | { |
135 | - $data = []; |
|
135 | + $data = [ ]; |
|
136 | 136 | // Different dbs do it different ways |
137 | 137 | $stats = null; |
138 | 138 | $handledStats = null; |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | } |
164 | 164 | if ($stats) { |
165 | 165 | $data = [ |
166 | - (int)$stats, |
|
167 | - (int)$handledStats, |
|
166 | + (int) $stats, |
|
167 | + (int) $handledStats, |
|
168 | 168 | ]; |
169 | 169 | } |
170 | 170 |