@@ -51,7 +51,7 @@ |
||
51 | 51 | self::$config['server']['publicPath'] = $baseAssetsUrl; |
52 | 52 | $useDevServer = getenv('NYS_PLUGIN_DEVSERVER'); |
53 | 53 | if ($useDevServer !== false) { |
54 | - self::$config['useDevServer'] = (bool)$useDevServer; |
|
54 | + self::$config['useDevServer'] = (bool) $useDevServer; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | $cache = Craft::$app->getCache(); |
406 | 406 | $file = $cache->getOrSet( |
407 | 407 | self::CACHE_KEY.$path, |
408 | - function () use ($path, $callback) { |
|
408 | + function() use ($path, $callback) { |
|
409 | 409 | $result = null; |
410 | 410 | $contents = @file_get_contents($path); |
411 | 411 | if ($contents) { |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | protected static function combinePaths(string ...$paths): string |
436 | 436 | { |
437 | 437 | $last_key = \count($paths) - 1; |
438 | - array_walk($paths, function (&$val, $key) use ($last_key) { |
|
438 | + array_walk($paths, function(&$val, $key) use ($last_key) { |
|
439 | 439 | switch ($key) { |
440 | 440 | case 0: |
441 | 441 | $val = rtrim($val, '/ '); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | if (!empty($string)) { |
44 | 44 | $string = strip_tags($string); |
45 | - $result = (string)Stringy::create($string)->truncate($length, $substring); |
|
45 | + $result = (string) Stringy::create($string)->truncate($length, $substring); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | return $result; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | if (!empty($string)) { |
68 | 68 | $string = strip_tags($string); |
69 | - $result = (string)Stringy::create($string)->safeTruncate($length, $substring); |
|
69 | + $result = (string) Stringy::create($string)->safeTruncate($length, $substring); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | return $result; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } else { |
113 | 113 | $variables['sitesMenuLabel'] = Craft::t( |
114 | 114 | 'site', |
115 | - $sites->getSiteById((int)$variables['currentSiteId'])->name |
|
115 | + $sites->getSiteById((int) $variables['currentSiteId'])->name |
|
116 | 116 | ); |
117 | 117 | } |
118 | 118 | } else { |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | } |
173 | 173 | |
174 | 174 | if (($parsed = parse_url(self::getBaseUrl($site))) === false) { |
175 | - Craft::warning('Unable to parse the site base URL: ' . $site->baseUrl); |
|
175 | + Craft::warning('Unable to parse the site base URL: '.$site->baseUrl); |
|
176 | 176 | continue; |
177 | 177 | } |
178 | 178 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | // Does the site URL specify a base path? |
185 | 185 | $parsedPath = !empty($parsed['path']) ? self::normalizePath($parsed['path']) : ''; |
186 | - if ($parsedPath && strpos($fullUri . '/', $parsedPath . '/') !== 0) { |
|
186 | + if ($parsedPath && strpos($fullUri.'/', $parsedPath.'/') !== 0) { |
|
187 | 187 | continue; |
188 | 188 | } |
189 | 189 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | protected static function getBaseUrl(Site $site): string |
258 | 258 | { |
259 | 259 | if ($site->baseUrl) { |
260 | - return rtrim(self::parseEnv($site->baseUrl), '/') . '/'; |
|
260 | + return rtrim(self::parseEnv($site->baseUrl), '/').'/'; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | return null; |
@@ -73,7 +73,7 @@ |
||
73 | 73 | |
74 | 74 | // Render the template with our vars passed in |
75 | 75 | try { |
76 | - $htmlText = Craft::$app->view->renderTemplate('webperf/' . $templatePath, $params); |
|
76 | + $htmlText = Craft::$app->view->renderTemplate('webperf/'.$templatePath, $params); |
|
77 | 77 | if ($minifier) { |
78 | 78 | // If SEOmatic is installed, get the title from it |
79 | 79 | $minify = Craft::$app->getPlugins()->getPlugin(self::MINIFY_PLUGIN_HANDLE); |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | if ($userAgent) { |
162 | 162 | $parser = new Parser($userAgent); |
163 | 163 | $sample->device = $parser->device->model; |
164 | - $sample->browser = $parser->browser->name . ' ' . $parser->browser->getVersion(); |
|
165 | - $sample->os = $parser->os->name . ' ' . $parser->os->getVersion(); |
|
164 | + $sample->browser = $parser->browser->name.' '.$parser->browser->getVersion(); |
|
165 | + $sample->os = $parser->os->name.' '.$parser->os->getVersion(); |
|
166 | 166 | $sample->mobile = $parser->isMobile(); |
167 | 167 | } |
168 | 168 | // Save the data sample |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $now = round(microtime(true) * 1000); |
188 | 188 | $cache = Craft::$app->getCache(); |
189 | 189 | $then = $cache->get(self::LAST_BEACON_CACHE_KEY); |
190 | - if (($then !== false) && ($now - (int)$then < Webperf::$settings->rateLimitMs)) { |
|
190 | + if (($then !== false) && ($now - (int) $then < Webperf::$settings->rateLimitMs)) { |
|
191 | 191 | $limited = true; |
192 | 192 | Craft::warning('Beacon ignored due to rate limiting', __METHOD__); |
193 | 193 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | } |
153 | 153 | $stats = Webperf::$plugin->profileTarget->stats; |
154 | 154 | $request = Craft::$app->getRequest(); |
155 | - $pageLoad = (int)($stats['database']['duration'] |
|
155 | + $pageLoad = (int) ($stats['database']['duration'] |
|
156 | 156 | + $stats['twig']['duration'] |
157 | 157 | + $stats['other']['duration']); |
158 | 158 | // Allocate a new DataSample, and fill it in |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | 'queryString' => $request->getQueryString(), |
163 | 163 | 'pageLoad' => $pageLoad, |
164 | 164 | 'craftTotalMs' => $pageLoad, |
165 | - 'craftDbMs' => (int)$stats['database']['duration'], |
|
166 | - 'craftDbCnt' => (int)$stats['database']['count'], |
|
167 | - 'craftTwigMs' => (int)$stats['twig']['duration'], |
|
168 | - 'craftTwigCnt' => (int)$stats['twig']['count'], |
|
169 | - 'craftOtherMs' => (int)$stats['other']['duration'], |
|
170 | - 'craftOtherCnt' => (int)$stats['other']['count'], |
|
171 | - 'craftTotalMemory' => (int)($stats['database']['memory'] |
|
165 | + 'craftDbMs' => (int) $stats['database']['duration'], |
|
166 | + 'craftDbCnt' => (int) $stats['database']['count'], |
|
167 | + 'craftTwigMs' => (int) $stats['twig']['duration'], |
|
168 | + 'craftTwigCnt' => (int) $stats['twig']['count'], |
|
169 | + 'craftOtherMs' => (int) $stats['other']['duration'], |
|
170 | + 'craftOtherCnt' => (int) $stats['other']['count'], |
|
171 | + 'craftTotalMemory' => (int) ($stats['database']['memory'] |
|
172 | 172 | + $stats['twig']['memory'] |
173 | 173 | + $stats['other']['memory']), |
174 | 174 | ]); |
@@ -92,8 +92,8 @@ |
||
92 | 92 | } |
93 | 93 | } |
94 | 94 | $this->stats[$cat]['count']++; |
95 | - $this->stats[$cat]['duration'] += (float)$timing['duration'] * 1000; |
|
96 | - $this->stats[$cat]['memory'] += (int)$timing['memoryDiff']; |
|
95 | + $this->stats[$cat]['duration'] += (float) $timing['duration'] * 1000; |
|
96 | + $this->stats[$cat]['memory'] += (int) $timing['memoryDiff']; |
|
97 | 97 | } |
98 | 98 | $this->stats['memory'] = memory_get_peak_usage(true); |
99 | 99 | if ($final) { |
@@ -107,7 +107,7 @@ |
||
107 | 107 | if (!empty($pageUrl)) { |
108 | 108 | $query->andWhere(['url' => $pageUrl]); |
109 | 109 | } |
110 | - if ((int)$siteId !== 0) { |
|
110 | + if ((int) $siteId !== 0) { |
|
111 | 111 | $query->andWhere(['siteId' => $siteId]); |
112 | 112 | } |
113 | 113 | $stats = $query->all(); |