| Conditions | 10 |
| Paths | 13 |
| Total Lines | 40 |
| Code Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 26 | public function checkStaticUpdatesAction($hash = '', $timeHash = '') { |
||
| 27 | if (is_string($hash) && !empty($_GET['files'])) { |
||
| 28 | $hashFiles = json_encode($_GET['files']); |
||
| 29 | if (!empty($this->module->template->config['staticUpdaterSalt'])) { |
||
| 30 | $hashFiles .= $this->module->template->config['staticUpdaterSalt']; |
||
| 31 | } |
||
| 32 | $hashFiles = md5($hashFiles); |
||
| 33 | if ($hash !== $hashFiles) { |
||
| 34 | exit(); |
||
| 35 | } |
||
| 36 | $timeStr = ''; |
||
| 37 | $urls = []; |
||
| 38 | foreach ($_GET['files'] as $href) { |
||
| 39 | $path = App::$cur->staticLoader->parsePath($href); |
||
| 40 | if (file_exists($path)) { |
||
| 41 | $urls[$href] = $path; |
||
| 42 | $timeStr .= filemtime($path); |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | $timeMd5 = md5($timeStr); |
||
| 47 | if ($timeHash === $timeMd5) { |
||
| 48 | exit(); |
||
| 49 | } |
||
| 50 | $cacheDir = Cache::getDir('static'); |
||
| 51 | $cssAll = ''; |
||
| 52 | if (!file_exists($cacheDir . 'all' . $timeMd5 . '.css')) { |
||
| 53 | foreach ($urls as $primaryUrl => $url) { |
||
| 54 | $source = file_get_contents($url); |
||
| 55 | $rootPath = substr($primaryUrl, 0, strrpos($primaryUrl, '/')); |
||
| 56 | $levelUpPath = substr($rootPath, 0, strrpos($rootPath, '/')); |
||
| 57 | $source = preg_replace('!url\((\'?"?)[\.]{2}!isU', 'url($1' . $levelUpPath, $source); |
||
| 58 | $source = preg_replace('!url\((\'?"?)[\.]{1}!isU', 'url($1' . $rootPath, $source); |
||
| 59 | $source = preg_replace('#url\(([\'"]){1}(?!http|https|/|data\:)([^/])#isU', 'url($1' . $rootPath . '/$2', $source); |
||
| 60 | $source = preg_replace('#url\((?!http|https|/|data\:|\'|")([^/])#isU', 'url(' . $rootPath . '/$1$2', $source); |
||
| 61 | $cssAll .= $source . "\n"; |
||
| 62 | } |
||
| 63 | file_put_contents($cacheDir . 'all' . $timeMd5 . '.css', $cssAll); |
||
| 64 | } |
||
| 65 | echo json_encode(['path' => '/' . $cacheDir . 'all' . $timeMd5 . '.css', 'timeHash' => $timeMd5]); |
||
| 66 | } |
||
| 86 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths