Complex classes like Smb often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Smb, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 26 | class Smb implements AdapterInterface |
||
| 27 | { |
||
| 28 | /** |
||
| 29 | * Options. |
||
| 30 | */ |
||
| 31 | public const OPTION_SYSTEM_FOLDER = 'system_folder'; |
||
| 32 | public const OPTION_ROOT = 'root'; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * System folders. |
||
| 36 | */ |
||
| 37 | protected const SYSTEM_TRASH = 'trash'; |
||
| 38 | protected const SYSTEM_TEMP = 'temp'; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * SMB share. |
||
| 42 | * |
||
| 43 | * @var IShare |
||
| 44 | */ |
||
| 45 | protected $share; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Logger. |
||
| 49 | * |
||
| 50 | * @var LoggerInterface |
||
| 51 | */ |
||
| 52 | protected $logger; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * SMB Root directory within share. |
||
| 56 | * |
||
| 57 | * @var string |
||
| 58 | */ |
||
| 59 | protected $root = ''; |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Balloon system folder. |
||
| 63 | * |
||
| 64 | * @var string |
||
| 65 | */ |
||
| 66 | protected $system_folder = '.balloon'; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * SMB storage. |
||
| 70 | */ |
||
| 71 | public function __construct(IShare $share, LoggerInterface $logger, array $config = []) |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Get SMB share. |
||
| 80 | */ |
||
| 81 | public function getShare(): IShare |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Get root path. |
||
| 88 | */ |
||
| 89 | public function getRoot(): string |
||
| 93 | |||
| 94 | /** |
||
| 95 | * Get system folder. |
||
| 96 | */ |
||
| 97 | public function getSystemFolder(): string |
||
| 101 | |||
| 102 | /** |
||
| 103 | * {@inheritdoc} |
||
| 104 | */ |
||
| 105 | public function hasNode(NodeInterface $node): bool |
||
| 119 | |||
| 120 | /** |
||
| 121 | * {@inheritdoc} |
||
| 122 | */ |
||
| 123 | public function deleteFile(File $file, ?int $version = null): ?array |
||
| 127 | |||
| 128 | /** |
||
| 129 | * {@inheritdoc} |
||
| 130 | */ |
||
| 131 | public function readonly(NodeInterface $node, bool $readonly = true): ?array |
||
| 145 | |||
| 146 | /** |
||
| 147 | * {@inheritdoc} |
||
| 148 | */ |
||
| 149 | public function forceDeleteFile(File $file, ?int $version = null): bool |
||
| 161 | |||
| 162 | /** |
||
| 163 | * {@inheritdoc} |
||
| 164 | */ |
||
| 165 | public function openReadStream(File $file) |
||
| 169 | |||
| 170 | /** |
||
| 171 | * {@inheritdoc} |
||
| 172 | */ |
||
| 173 | public function storeFile(File $file, ObjectId $session): array |
||
| 217 | |||
| 218 | /** |
||
| 219 | * {@inheritdoc} |
||
| 220 | */ |
||
| 221 | public function createCollection(Collection $parent, string $name): array |
||
| 230 | |||
| 231 | /** |
||
| 232 | * {@inheritdoc} |
||
| 233 | */ |
||
| 234 | public function deleteCollection(Collection $collection): ?array |
||
| 238 | |||
| 239 | /** |
||
| 240 | * {@inheritdoc} |
||
| 241 | */ |
||
| 242 | public function forceDeleteCollection(Collection $collection): bool |
||
| 254 | |||
| 255 | /** |
||
| 256 | * {@inheritdoc} |
||
| 257 | */ |
||
| 258 | public function rename(NodeInterface $node, string $new_name): ?array |
||
| 270 | |||
| 271 | /** |
||
| 272 | * {@inheritdoc} |
||
| 273 | */ |
||
| 274 | public function move(NodeInterface $node, Collection $parent): ?array |
||
| 286 | |||
| 287 | /** |
||
| 288 | * {@inheritdoc} |
||
| 289 | */ |
||
| 290 | public function undelete(NodeInterface $node): ?array |
||
| 310 | |||
| 311 | /** |
||
| 312 | * {@inheritdoc} |
||
| 313 | */ |
||
| 314 | public function storeTemporaryFile($stream, User $user, ?ObjectId $session = null): ObjectId |
||
| 339 | |||
| 340 | /** |
||
| 341 | * Test connection to storage. |
||
| 342 | */ |
||
| 343 | public function test(): bool |
||
| 351 | |||
| 352 | /** |
||
| 353 | * Set options. |
||
| 354 | */ |
||
| 355 | protected function setOptions(array $config = []): self |
||
| 371 | |||
| 372 | /** |
||
| 373 | * Create system folder if not exists. |
||
| 374 | */ |
||
| 375 | protected function getSystemPath(string $name): string |
||
| 404 | |||
| 405 | /** |
||
| 406 | * Move node to trash folder. |
||
| 407 | */ |
||
| 408 | protected function deleteNode(NodeInterface $node): array |
||
| 426 | |||
| 427 | /** |
||
| 428 | * Get SMB path from node. |
||
| 429 | */ |
||
| 430 | protected function getPath(NodeInterface $node): string |
||
| 444 | |||
| 445 | /** |
||
| 446 | * Store stream content. |
||
| 447 | */ |
||
| 448 | protected function storeStream($stream, string $path): int |
||
| 462 | } |
||
| 463 |
Scrutinizer analyzes your
composer.json/composer.lockfile 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.