Complex classes like StorageManager 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 StorageManager, and based on these observations, apply Extract Interface, too.
| 1 | <?php | ||
| 14 | class StorageManager | ||
| 15 | { | ||
| 16 | /** | ||
| 17 | * @var Storage | ||
| 18 | */ | ||
| 19 | protected $storage; | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @var ImagineFactory | ||
| 23 | */ | ||
| 24 | protected $imagineFactory; | ||
| 25 | |||
| 26 | /** | ||
| 27 | * Construct | ||
| 28 | * | ||
| 29 | * @param Storage $storage | ||
| 30 | * @param ImagineFactory $imagineFactory | ||
| 31 | */ | ||
| 32 | public function __construct(Storage $storage, ImagineFactory $imagineFactory = null) | ||
| 37 | |||
| 38 | /** | ||
| 39 | * File Exists | ||
| 40 | * | ||
| 41 | * @param string $filename Path File | ||
| 42 | * | ||
| 43 | * @return bool | ||
| 44 | */ | ||
| 45 | public function exists($filename) | ||
| 54 | |||
| 55 | /** | ||
| 56 | * Get Size | ||
| 57 | * | ||
| 58 | * @param string $filename Path File | ||
| 59 | * | ||
| 60 | * @return bool | ||
| 61 | */ | ||
| 62 | public function size($filename) | ||
| 71 | |||
| 72 | /** | ||
| 73 | * Get MimeType File | ||
| 74 | * | ||
| 75 | * @param string $filename Path File | ||
| 76 | * | ||
| 77 | * @return bool | ||
| 78 | */ | ||
| 79 | public function mimeType($filename) | ||
| 88 | |||
| 89 | /** | ||
| 90 | * Path is Directory | ||
| 91 | * | ||
| 92 | * @param string $path Path Directory | ||
| 93 | * | ||
| 94 | * @return bool | ||
| 95 | */ | ||
| 96 | public function isDir($path) | ||
| 106 | |||
| 107 | /** | ||
| 108 | * Is File | ||
| 109 | * | ||
| 110 | * @param string $filename Path File | ||
| 111 | * | ||
| 112 | * @return bool | ||
| 113 | */ | ||
| 114 | public function isFile($filename) | ||
| 118 | |||
| 119 | /** | ||
| 120 | * Get Meta Data | ||
| 121 | * | ||
| 122 | * @param string $filename Path File | ||
| 123 | * | ||
| 124 | * @return bool | ||
| 125 | */ | ||
| 126 | public function metaData($filename) | ||
| 135 | |||
| 136 | /** | ||
| 137 | * Read Content File | ||
| 138 | * | ||
| 139 | * @param string $filename Path File | ||
| 140 | * | ||
| 141 | * @return string | ||
| 142 | */ | ||
| 143 | public function readFile($filename) | ||
| 147 | |||
| 148 | /** | ||
| 149 | * Delete File | ||
| 150 | * | ||
| 151 | * @param string $filename Path File | ||
| 152 | * | ||
| 153 | * @return bool | ||
| 154 | */ | ||
| 155 | public function deleteFile($filename) | ||
| 163 | |||
| 164 | /** | ||
| 165 | * Delete Folder | ||
| 166 | * | ||
| 167 | * @param string $folder | ||
| 168 | * | ||
| 169 | * @return bool | ||
| 170 | */ | ||
| 171 | public function deleteFolder($folder) | ||
| 179 | |||
| 180 | /** | ||
| 181 | * Files in Folder | ||
| 182 | * | ||
| 183 | * @param string $path | ||
| 184 | * @param bool $recursive | ||
| 185 | * | ||
| 186 | * @return array | ||
| 187 | */ | ||
| 188 | public function files($path, $recursive = false) | ||
| 196 | |||
| 197 | /** | ||
| 198 | * UploadFile | ||
| 199 | * | ||
| 200 | * @param UploadedFile|string $file Uploaded File | ||
| 201 | * @param string $folder String Folder | ||
| 202 | * @param string $name String Name | ||
| 203 | * @param bool $override Boolean Over Ride | ||
| 204 | * @param array $config Array Config Upload | ||
| 205 | * | ||
| 206 | * @return bool | ||
| 207 | */ | ||
| 208 | public function uploadFile($file, $folder = null, $name = null, $override = false, array $config = []) | ||
| 220 | |||
| 221 | /** | ||
| 222 | * Upload Image | ||
| 223 | * | ||
| 224 | * @param UploadedFile $file Uploaded File | ||
| 225 | * @param string $folder String Folder | ||
| 226 | * @param string $name String Name | ||
| 227 | * @param array $options Array Options | ||
| 228 | * @param bool $override Boolean Over Ride | ||
| 229 | * @param array $config Array Config Upload | ||
| 230 | * | ||
| 231 | * @return bool | ||
| 232 | */ | ||
| 233 | public function uploadImage( | ||
| 277 | |||
| 278 | /** | ||
| 279 | * Parse Filename | ||
| 280 | * | ||
| 281 | * @param UploadedFile|string $file Uploaded File | ||
| 282 | * @param string $name String Name | ||
| 283 | * @param string $folder String Folder | ||
| 284 | * @param bool $override Boolean Over Ride | ||
| 285 | * | ||
| 286 | * @return bool|array | ||
| 287 | */ | ||
| 288 | protected function parseFile($file, $folder = null, $name = null, $override = false) | ||
| 330 | |||
| 331 | /** | ||
| 332 | * Crop Image | ||
| 333 | * | ||
| 334 | * @param string $filename | ||
| 335 | * @param int $width | ||
| 336 | * @param int $height | ||
| 337 | * @param int $x | ||
| 338 | * @param int $y | ||
| 339 | * | ||
| 340 | * @return bool | ||
| 341 | */ | ||
| 342 | public function cropImage( | ||
| 364 | |||
| 365 | /** | ||
| 366 | * Watermark Image | ||
| 367 | * | ||
| 368 | * @param string $filename | ||
| 369 | * @param int $width | ||
| 370 | * @param int $height | ||
| 371 | * @param int $x | ||
| 372 | * @param int $y | ||
| 373 | * | ||
| 374 | * @return bool | ||
| 375 | */ | ||
| 376 | public function watermarkImage( | ||
| 405 | |||
| 406 | /** | ||
| 407 | * Dynamically handle calls into the query instance. | ||
| 408 | * | ||
| 409 | * @param string $method | ||
| 410 | * @param array $parameters | ||
| 411 | * @return mixed | ||
| 412 | */ | ||
| 413 | public function __call($method, $parameters) | ||
| 417 | } | ||
| 418 | 
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.