Conditions | 15 |
Paths | 62 |
Total Lines | 76 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 240 |
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:
Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.
There are several approaches to avoid long parameter lists:
1 | <?php |
||
147 | protected function recursiveIterator(Collection $parent, Collection $mount, IShare $share, User $user, Smb $smb, string $path, bool $recursive, int $action): void |
||
148 | { |
||
149 | $system_path = $path.DIRECTORY_SEPARATOR.$smb->getSystemFolder(); |
||
150 | |||
151 | if ($path === $system_path) { |
||
152 | return; |
||
153 | } |
||
154 | |||
155 | $this->logger->debug('sync smb path ['.$path.'] in mount ['.$mount->getId().'] from operation ['.$action.']', [ |
||
156 | 'category' => get_class($this), |
||
157 | 'recursive' => $recursive, |
||
158 | ]); |
||
159 | |||
160 | $system_path = $path.DIRECTORY_SEPARATOR.$smb->getSystemFolder(); |
||
161 | |||
162 | if ($path === $system_path) { |
||
163 | return; |
||
164 | } |
||
165 | |||
166 | try { |
||
167 | $node = $share->stat($path); |
||
168 | } catch (NotFoundException $e) { |
||
|
|||
169 | if ($action === INotifyHandler::NOTIFY_REMOVED) { |
||
170 | $node = $parent->getChild(Helper::mb_basename($path)); |
||
171 | $node->getParent()->setStorage($this->dummy); |
||
172 | $node->delete(true); |
||
173 | } |
||
174 | |||
175 | return; |
||
176 | } |
||
177 | |||
178 | if ($node->isDirectory()) { |
||
179 | if ($path === DIRECTORY_SEPARATOR) { |
||
180 | $child = $parent; |
||
181 | } else { |
||
182 | if ($parent->childExists($node->getName())) { |
||
183 | $child = $parent->getChild($node->getName()); |
||
184 | } else { |
||
185 | $child = $parent->addDirectory($node->getName(), $this->getAttributes($mount, $share, $node)); |
||
186 | } |
||
187 | } |
||
188 | |||
189 | if ($recursive === true) { |
||
190 | $child->setStorage($this->dummy); |
||
191 | $nodes = []; |
||
192 | |||
193 | foreach ($share->dir($path) as $node) { |
||
194 | if ($node->getPath() === $system_path) { |
||
195 | continue; |
||
196 | } |
||
197 | |||
198 | $nodes[] = $node->getName(); |
||
199 | $child_path = ($path === DIRECTORY_SEPARATOR) ? $path.$node->getName() : $path.DIRECTORY_SEPARATOR.$node->getName(); |
||
200 | |||
201 | try { |
||
202 | $this->recursiveIterator($child, $mount, $share, $user, $smb, $child_path, $recursive, $action); |
||
203 | } catch (\Exception $e) { |
||
204 | $this->logger->error('failed sync child node ['.$child_path.'] in smb mount', [ |
||
205 | 'category' => get_class($this), |
||
206 | 'exception' => $e, |
||
207 | ]); |
||
208 | } |
||
209 | } |
||
210 | |||
211 | foreach ($child->getChildNodes() as $sub_child) { |
||
212 | $sub_name = Normalizer::normalize($sub_child->getName()); |
||
213 | |||
214 | if (!in_array($sub_name, $nodes)) { |
||
215 | $sub_child->delete(true); |
||
216 | } |
||
217 | } |
||
218 | } |
||
219 | } else { |
||
220 | $this->syncFile($parent, $mount, $node, $action, $share, $user); |
||
221 | } |
||
222 | } |
||
223 | |||
301 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.