| Total Complexity | 46 |
| Total Lines | 315 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
Complex classes like BeforeAllFilesystem 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.
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 BeforeAllFilesystem, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 39 | final class BeforeAllFilesystem implements FilesystemInterface |
||
| 40 | { |
||
| 41 | use MountableFilesystemTrait; |
||
| 42 | use FilesystemFlagsImplementationTrait; |
||
| 43 | |||
| 44 | /** @var callable */ |
||
| 45 | private $callback; |
||
| 46 | private FilesystemInterface $filesystem; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param callable(string,array):void $callback |
||
| 50 | */ |
||
| 51 | public function __construct( |
||
| 52 | callable $callback, |
||
| 53 | FilesystemInterface $filesystem |
||
| 54 | ) { |
||
| 55 | $this->callback = $callback; |
||
| 56 | $this->filesystem = $filesystem; |
||
| 57 | } |
||
| 58 | |||
| 59 | private function getFilesystem(): FilesystemInterface |
||
| 60 | { |
||
| 61 | return $this->filesystem; |
||
| 62 | } |
||
| 63 | |||
| 64 | public function getattr(string $path, Stat $stat): int |
||
| 65 | { |
||
| 66 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 67 | return $this->getFilesystem()->getattr($path, $stat); |
||
| 68 | } |
||
| 69 | |||
| 70 | public function readlink(string $path, CStringBuffer $buffer, int $size): int |
||
| 71 | { |
||
| 72 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 73 | return $this->getFilesystem()->readlink($path, $buffer, $size); |
||
| 74 | } |
||
| 75 | |||
| 76 | /** @deprecated */ |
||
| 77 | public function getdir(string $path, FuseDirHandle $dirhandle, FuseDirFill $dirfill): int |
||
| 78 | { |
||
| 79 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 80 | /** @psalm-suppress DeprecatedMethod */ |
||
| 81 | return $this->getFilesystem()->getdir($path, $dirhandle, $dirfill); |
||
| 82 | } |
||
| 83 | |||
| 84 | public function mknod(string $path, int $mode, int $dev): int |
||
| 85 | { |
||
| 86 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 87 | return $this->getFilesystem()->mknod($path, $mode, $dev); |
||
| 88 | } |
||
| 89 | |||
| 90 | public function mkdir(string $path, int $mode): int |
||
| 91 | { |
||
| 92 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 93 | return $this->getFilesystem()->mkdir($path, $mode); |
||
| 94 | } |
||
| 95 | |||
| 96 | public function unlink(string $path): int |
||
| 97 | { |
||
| 98 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 99 | return $this->getFilesystem()->unlink($path); |
||
| 100 | } |
||
| 101 | |||
| 102 | public function rmdir(string $path): int |
||
| 103 | { |
||
| 104 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 105 | return $this->getFilesystem()->rmdir($path); |
||
| 106 | } |
||
| 107 | |||
| 108 | public function symlink(string $path, string $link): int |
||
| 109 | { |
||
| 110 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 111 | return $this->getFilesystem()->symlink($path, $link); |
||
| 112 | } |
||
| 113 | |||
| 114 | public function rename(string $from, string $to): int |
||
| 115 | { |
||
| 116 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 117 | return $this->getFilesystem()->rename($from, $to); |
||
| 118 | } |
||
| 119 | |||
| 120 | public function link(string $path, string $link): int |
||
| 121 | { |
||
| 122 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 123 | return $this->getFilesystem()->link($path, $link); |
||
| 124 | } |
||
| 125 | |||
| 126 | public function chmod(string $path, int $mode): int |
||
| 130 | } |
||
| 131 | |||
| 132 | public function chown(string $path, int $uid, int $gid): int |
||
| 133 | { |
||
| 134 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 135 | return $this->getFilesystem()->chown($path, $uid, $gid); |
||
| 136 | } |
||
| 137 | |||
| 138 | public function truncate(string $path, int $offset): int |
||
| 139 | { |
||
| 140 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 141 | return $this->getFilesystem()->truncate($path, $offset); |
||
| 142 | } |
||
| 143 | |||
| 144 | public function utime(string $path, UtimBuf $utime_buf): int |
||
| 145 | { |
||
| 146 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 147 | return $this->getFilesystem()->utime($path, $utime_buf); |
||
| 148 | } |
||
| 149 | |||
| 150 | public function open(string $path, FuseFileInfo $fuse_file_info): int |
||
| 151 | { |
||
| 152 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 153 | return $this->getFilesystem()->open($path, $fuse_file_info); |
||
| 154 | } |
||
| 155 | |||
| 156 | public function read(string $path, CBytesBuffer $buffer, int $size, int $offset, FuseFileInfo $fuse_file_info): int |
||
| 157 | { |
||
| 158 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 159 | return $this->getFilesystem()->read($path, $buffer, $size, $offset, $fuse_file_info); |
||
| 160 | } |
||
| 161 | |||
| 162 | public function write(string $path, string $buffer, int $size, int $offset, FuseFileInfo $fuse_file_info): int |
||
| 163 | { |
||
| 164 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 165 | return $this->getFilesystem()->write($path, $buffer, $size, $offset, $fuse_file_info); |
||
| 166 | } |
||
| 167 | |||
| 168 | public function statfs(string $path, StatVfs $statvfs): int |
||
| 169 | { |
||
| 170 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 171 | return $this->getFilesystem()->statfs($path, $statvfs); |
||
| 172 | } |
||
| 173 | |||
| 174 | public function flush(string $path, FuseFileInfo $fuse_file_info): int |
||
| 175 | { |
||
| 176 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 177 | return $this->getFilesystem()->flush($path, $fuse_file_info); |
||
| 178 | } |
||
| 179 | |||
| 180 | public function release(string $path, FuseFileInfo $fuse_file_info): int |
||
| 181 | { |
||
| 182 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 183 | return $this->getFilesystem()->release($path, $fuse_file_info); |
||
| 184 | } |
||
| 185 | |||
| 186 | public function fsync(string $path, int $flags, FuseFileInfo $fuse_file_info): int |
||
| 187 | { |
||
| 188 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 189 | return $this->getFilesystem()->fsync($path, $flags, $fuse_file_info); |
||
| 190 | } |
||
| 191 | |||
| 192 | public function setxattr(string $path, string $name, string $value, int $size): int |
||
| 193 | { |
||
| 194 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 195 | return $this->getFilesystem()->setxattr($path, $name, $value, $size); |
||
| 196 | } |
||
| 197 | |||
| 198 | public function getxattr(string $path, string $name, ?string &$value, int $size): int |
||
| 199 | { |
||
| 200 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 201 | return $this->getFilesystem()->getxattr($path, $name, $value, $size); |
||
| 202 | } |
||
| 203 | |||
| 204 | public function listxattr(string $path, ?string &$value, int $size): int |
||
| 205 | { |
||
| 206 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 207 | return $this->getFilesystem()->listxattr($path, $value, $size); |
||
| 208 | } |
||
| 209 | |||
| 210 | public function removexattr(string $size, string $name): int |
||
| 211 | { |
||
| 212 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 213 | return $this->getFilesystem()->removexattr($size, $name); |
||
| 214 | } |
||
| 215 | |||
| 216 | public function opendir(string $path, FuseFileInfo $fuse_file_info): int |
||
| 217 | { |
||
| 218 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 219 | return $this->getFilesystem()->opendir($path, $fuse_file_info); |
||
| 220 | } |
||
| 221 | |||
| 222 | public function readdir( |
||
| 223 | string $path, |
||
| 224 | FuseReadDirBuffer $buf, |
||
| 225 | FuseFillDir $filler, |
||
| 226 | int $offset, |
||
| 227 | FuseFileInfo $fuse_file_info |
||
| 228 | ): int { |
||
| 229 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 230 | return $this->getFilesystem()->readdir($path, $buf, $filler, $offset, $fuse_file_info); |
||
| 231 | } |
||
| 232 | |||
| 233 | public function releasedir(string $path, FuseFileInfo $fuse_file_info): int |
||
| 234 | { |
||
| 235 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 236 | return $this->getFilesystem()->releasedir($path, $fuse_file_info); |
||
| 237 | } |
||
| 238 | |||
| 239 | public function fsyncdir(string $path, FuseFileInfo $fuse_file_info): int |
||
| 240 | { |
||
| 241 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 242 | return $this->getFilesystem()->fsyncdir($path, $fuse_file_info); |
||
| 243 | } |
||
| 244 | |||
| 245 | public function init(FuseConnInfo $conn): ?FusePrivateData |
||
| 246 | { |
||
| 247 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 248 | return $this->getFilesystem()->init($conn); |
||
| 249 | } |
||
| 250 | |||
| 251 | public function destroy(?FusePrivateData $private_data): void |
||
| 252 | { |
||
| 253 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 254 | $this->getFilesystem()->destroy($private_data); |
||
| 255 | } |
||
| 256 | |||
| 257 | public function access(string $path, int $mode): int |
||
| 258 | { |
||
| 259 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 260 | return $this->getFilesystem()->access($path, $mode); |
||
| 261 | } |
||
| 262 | |||
| 263 | public function create(string $path, int $mode, FuseFileInfo $fuse_file_info): int |
||
| 267 | } |
||
| 268 | |||
| 269 | public function ftruncate(string $path, int $offset, FuseFileInfo $fuse_file_info): int |
||
| 270 | { |
||
| 271 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 272 | return $this->getFilesystem()->ftruncate($path, $offset, $fuse_file_info); |
||
| 273 | } |
||
| 274 | |||
| 275 | public function fgetattr(string $path, Stat $stat, FuseFileInfo $fuse_file_info): int |
||
| 276 | { |
||
| 277 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 278 | return $this->getFilesystem()->fgetattr($path, $stat, $fuse_file_info); |
||
| 279 | } |
||
| 280 | |||
| 281 | public function lock(string $path, FuseFileInfo $fuse_file_info, int $cmd, Flock $flock): int |
||
| 282 | { |
||
| 283 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 284 | return $this->getFilesystem()->lock($path, $fuse_file_info, $cmd, $flock); |
||
| 285 | } |
||
| 286 | |||
| 287 | /** |
||
| 288 | * @param TypedCDataArray<TimeSpec> $tv |
||
| 289 | */ |
||
| 290 | public function utimens(string $path, TypedCDataArray $tv): int |
||
| 291 | { |
||
| 292 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 293 | return $this->getFilesystem()->utimens($path, $tv); |
||
| 294 | } |
||
| 295 | |||
| 296 | public function bmap(string $path, int $blocksize, int &$idx): int |
||
| 297 | { |
||
| 298 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 299 | return $this->getFilesystem()->bmap($path, $blocksize, $idx); |
||
| 300 | } |
||
| 301 | |||
| 302 | public function ioctl( |
||
| 303 | string $path, |
||
| 304 | int $cmd, |
||
| 305 | FuseIoctlArgPointer $arg, |
||
| 306 | FuseFileInfo $fuse_file_info, |
||
| 307 | int $flags, |
||
| 308 | FuseIoctlDataPointer $data |
||
| 309 | ): int { |
||
| 310 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 311 | return $this->getFilesystem()->ioctl($path, $cmd, $arg, $fuse_file_info, $flags, $data); |
||
| 312 | } |
||
| 313 | |||
| 314 | public function poll( |
||
| 315 | string $path, |
||
| 316 | FuseFileInfo $fuse_file_info, |
||
| 317 | FusePollHandle $fuse_pollhandle, |
||
| 318 | int &$reventsp |
||
| 319 | ): int { |
||
| 320 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 321 | return $this->getFilesystem()->poll($path, $fuse_file_info, $fuse_pollhandle, $reventsp); |
||
| 322 | } |
||
| 323 | |||
| 324 | public function writeBuf(string $path, FuseBufVec $buf, int $offset, FuseFileInfo $fuse_file_info): int |
||
| 325 | { |
||
| 326 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 327 | return $this->getFilesystem()->writeBuf($path, $buf, $offset, $fuse_file_info); |
||
| 328 | } |
||
| 329 | |||
| 330 | /** |
||
| 331 | * @param TypedCDataArray<FuseBufVec> $bufp |
||
| 332 | */ |
||
| 333 | public function readBuf( |
||
| 334 | string $path, |
||
| 335 | TypedCDataArray $bufp, |
||
| 336 | int $size, |
||
| 337 | int $offset, |
||
| 338 | FuseFileInfo $fuse_file_info |
||
| 339 | ): int { |
||
| 340 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 341 | return $this->getFilesystem()->readBuf($path, $bufp, $size, $offset, $fuse_file_info); |
||
| 342 | } |
||
| 343 | |||
| 344 | public function flock(string $path, FuseFileInfo $fuse_file_info, int $op): int |
||
| 345 | { |
||
| 346 | ($this->callback)(__FUNCTION__, func_get_args()); |
||
| 347 | return $this->getFilesystem()->flock($path, $fuse_file_info, $op); |
||
| 348 | } |
||
| 349 | |||
| 350 | public function fallocate(string $path, int $mode, int $offset, FuseFileInfo $fuse_file_info): int |
||
| 354 | } |
||
| 355 | } |
||
| 356 |
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