Conditions | 16 |
Paths | 323 |
Total Lines | 64 |
Code Lines | 46 |
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 |
||
63 | protected function runForFolder($parentID) |
||
64 | { |
||
65 | if ($this->oneFolderOnlyID && $this->oneFolderOnlyID !== $parentID) { |
||
66 | return; |
||
67 | } |
||
68 | if ($parentID) { |
||
69 | $folder = Folder::get_by_id($parentID); |
||
70 | FlushNowImplementor::do_flush('<h3>Processing Folder: ' . $folder->getFilename() . '</h3>'); |
||
71 | } else { |
||
72 | FlushNowImplementor::do_flush('<h3>Processing Root Folder</h3>'); |
||
73 | } |
||
74 | $sqlQuery = new SQLSelect(); |
||
75 | $sqlQuery->setFrom('File'); |
||
76 | $sqlQuery->selectField('ID'); |
||
77 | $sqlQuery->addWhere(['ParentID' => $parentID]); |
||
78 | $sqlQuery->setOrderBy('Name'); |
||
79 | |||
80 | // Execute and return a Query object |
||
81 | $result = $sqlQuery->execute(); |
||
82 | foreach ($result as $row) { |
||
83 | $file = File::get_by_id($row['ID']); |
||
84 | if (null !== $file) { |
||
85 | $name = $file->getFilename(); |
||
86 | if (!$name) { |
||
87 | $file->write(); |
||
88 | $name = $file->getFilename(); |
||
89 | } |
||
90 | if ($this->oneFileOnlyID && $this->oneFileOnlyID !== $file->ID) { |
||
91 | continue; |
||
92 | } |
||
93 | if ($name) { |
||
94 | if ($this->updateLocation) { |
||
95 | $this->updateLocationForOneFile($file, $name); |
||
96 | $file = File::get_by_id($row['ID']); |
||
97 | } |
||
98 | |||
99 | try { |
||
100 | if ($file->exists()) { |
||
101 | FlushNowImplementor::do_flush('... Publishing: ' . $name . ', ID = ' . $file->ID); |
||
102 | if ($this->generateThumbnails) { |
||
103 | $this->admin->generateThumbnails($file); |
||
104 | } |
||
105 | $file->forceChange(); |
||
106 | $file->write(); |
||
107 | $file->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); |
||
108 | $test = DB::query('SELECT COUNT(ID) FROM File_Live WHERE ID = ' . $file->ID)->value(); |
||
109 | if (0 === (int) $test) { |
||
110 | FlushNowImplementor::do_flush('... error finding: ' . $name, 'deleted'); |
||
111 | } |
||
112 | } else { |
||
113 | FlushNowImplementor::do_flush('... Error in publishing V2 ...' . print_r($file->toMap(), 1), 'deleted'); |
||
114 | } |
||
115 | } catch (\Exception $exception) { |
||
116 | FlushNowImplementor::do_flush('... Error in publishing V1 ...' . print_r($file->toMap(), 1), 'deleted'); |
||
117 | } |
||
118 | } else { |
||
119 | FlushNowImplementor::do_flush('... Error in finding name for ' . print_r($file->toMap(), 1), 'deleted'); |
||
120 | } |
||
121 | |||
122 | $file->destroy(); |
||
123 | } |
||
124 | |||
125 | if ($file instanceof Folder) { |
||
126 | $this->runForFolder($file->ID); |
||
127 | } |
||
192 |
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