| Conditions | 3 |
| Paths | 2 |
| Total Lines | 59 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 50 | public function sourceRecords($params = [], $sort = null, $limit = null) |
||
| 51 | { |
||
| 52 | $records = []; |
||
| 53 | |||
| 54 | // Get the query to apply across all variants: looks at all subsites, translations, live stage only. |
||
| 55 | $crossVariant = (function ($dataQuery) { |
||
| 56 | $params = [ |
||
| 57 | 'Subsite.filter' => false, |
||
| 58 | 'Versioned.mode' => 'stage', |
||
| 59 | 'Versioned.stage' => Versioned::LIVE, |
||
| 60 | ]; |
||
| 61 | |||
| 62 | return $dataQuery->setDataQueryParam($params); |
||
| 63 | }); |
||
| 64 | |||
| 65 | // Total. |
||
| 66 | $records[] = [ |
||
| 67 | 'Name' => _t( |
||
| 68 | __CLASS__ . '.TotalPageCount', |
||
| 69 | 'Total live page count, across all translations and subsites' |
||
| 70 | ), |
||
| 71 | 'Count' => $crossVariant(SiteTree::get())->count(), |
||
| 72 | ]; |
||
| 73 | |||
| 74 | if (class_exists(Subsite::class)) { |
||
| 75 | // Main site. |
||
| 76 | $records[] = [ |
||
| 77 | 'Name' => _t(__CLASS__ . '.PagesForMainSite', '- in the main site'), |
||
| 78 | 'Count' => $crossVariant(SiteTree::get()) |
||
| 79 | ->filter(['SubsiteID' => 0]) |
||
| 80 | ->count(), |
||
| 81 | ]; |
||
| 82 | |||
| 83 | // Per subsite. |
||
| 84 | $subsites = Subsite::get(); |
||
| 85 | foreach ($subsites as $subsite) { |
||
| 86 | $records[] = [ |
||
| 87 | 'Name' => _t( |
||
| 88 | __CLASS__ . '.PagesForSubsite', |
||
| 89 | "- in the subsite '{SubsiteTitle}'", |
||
| 90 | ['SubsiteTitle' => $subsite->Title] |
||
| 91 | ), |
||
| 92 | 'Count' => $crossVariant(SiteTree::get()) |
||
| 93 | ->filter(['SubsiteID' => $subsite->ID]) |
||
| 94 | ->count(), |
||
| 95 | ]; |
||
| 96 | } |
||
| 97 | } |
||
| 98 | |||
| 99 | // Files. |
||
| 100 | $records[] = [ |
||
| 101 | 'Name' => _t(__CLASS__ . '.FileCount', 'File count'), |
||
| 102 | 'Count' => File::get() |
||
| 103 | ->setDataQueryParam('Subsite.filter', false) |
||
| 104 | ->filter(['ClassName:not' => Folder::class]) |
||
| 105 | ->count(), |
||
| 106 | ]; |
||
| 107 | |||
| 108 | return ArrayList::create($records); |
||
| 109 | } |
||
| 128 |
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