Conditions | 14 |
Paths | 11 |
Total Lines | 63 |
Code Lines | 43 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
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 |
||
13 | protected function applyOne(DataQuery $query) |
||
14 | { |
||
15 | $sql = ''; |
||
16 | $array = [0 => 0]; |
||
17 | $schema = DataObject::getSchema(); |
||
18 | $className = $query->dataClass(); |
||
19 | $baseTable = $schema->baseDataTable($className); |
||
20 | switch ($this->getValue()) { |
||
21 | |||
22 | case 'MODIFIED': |
||
23 | $className = $query->dataClass(); |
||
24 | $objects = $className::get(); |
||
25 | foreach ($objects as $obj) { |
||
26 | if ($obj->isModifiedOnDraft() && $obj->isPublished()) { |
||
27 | $array[$obj->ID] = $obj->ID; |
||
28 | } |
||
29 | } |
||
30 | |||
31 | break; |
||
32 | |||
33 | case Versioned::LIVE: |
||
34 | $sql = 'SELECT "ID" FROM "'.$baseTable.'_Live"'; |
||
35 | |||
36 | break; |
||
37 | |||
38 | case Versioned::DRAFT: |
||
39 | $sql = ' |
||
40 | SELECT "'.$baseTable.'"."ID" |
||
41 | FROM "'.$baseTable.'" |
||
42 | LEFT JOIN "'.$baseTable.'_Live" ON "'.$baseTable.'_Live"."ID" = "'.$baseTable.'"."ID" |
||
43 | WHERE "'.$baseTable.'_Live"."ID" IS NULL'; |
||
44 | |||
45 | break; |
||
46 | |||
47 | case 'DRAFT_ERROR': |
||
48 | $sql = ' |
||
49 | SELECT "'.$baseTable.'_Live"."ID" |
||
50 | FROM "'.$baseTable.'_Live" |
||
51 | LEFT JOIN '.$baseTable.' ON '.$baseTable.'_Live.ID = '.$baseTable.'.ID |
||
52 | WHERE '.$baseTable.'.ID IS NULL'; |
||
53 | |||
54 | break; |
||
55 | |||
56 | case 'PUBLISHED_CLEAN': |
||
57 | $objects = $className::get(); |
||
58 | foreach ($objects as $obj) { |
||
59 | if (!$obj->isModifiedOnDraft() && $obj->isPublished()) { |
||
60 | $array[$obj->ID] = $obj->ID; |
||
61 | } |
||
62 | } |
||
63 | break; |
||
64 | default: |
||
65 | return $query; |
||
66 | } |
||
67 | |||
68 | if ($sql) { |
||
69 | $rows = DB::query($sql); |
||
70 | foreach ($rows as $row) { |
||
71 | $array[$row['ID']] = $row['ID']; |
||
72 | } |
||
73 | } |
||
74 | |||
75 | return $query->where("\"{$baseTable}\".\"ID\" IN (" . implode(',', $array) . ')'); |
||
76 | } |
||
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