| Conditions | 12 |
| Paths | 1052 |
| Total Lines | 67 |
| Code Lines | 45 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 77 | public function handle(Filesystem $filesystem, Dumper $dumper) |
||
| 78 | { |
||
| 79 | $this->info('Start Database Backup'); |
||
| 80 | |||
| 81 | $driver = dbm_driver(); |
||
| 82 | |||
| 83 | $hostname = config('database.connections.' . $driver . '.host', '127.0.0.1'); |
||
| 84 | $port = config('database.connections.' . $driver . '.port', '3306'); |
||
| 85 | $database = config('database.connections.' . $driver . '.database', 'dbm'); |
||
| 86 | $table = ($this->option('table') != null) ? $this->option('table') : ''; |
||
| 87 | $username = config('database.connections.' . $driver . '.username', 'root'); |
||
| 88 | $password = config('database.connections.' . $driver . '.password', ''); |
||
| 89 | |||
| 90 | try |
||
| 91 | { |
||
| 92 | $directory = (config('dbm.backup.dir', 'backups') != '') |
||
| 93 | ? DIRECTORY_SEPARATOR . config('dbm.backup.dir', 'backups') |
||
| 94 | : ''; |
||
| 95 | $directoryPath = DBM::getPathPrefix() . $directory . DIRECTORY_SEPARATOR . $driver; |
||
| 96 | $filePath = $directoryPath . DIRECTORY_SEPARATOR . $this->getFileName($table, $database); |
||
| 97 | |||
| 98 | if (!File::isDirectory($directoryPath)) { |
||
| 99 | |||
| 100 | File::makeDirectory($directoryPath, 0777, true, true); |
||
| 101 | |||
| 102 | } |
||
| 103 | |||
| 104 | $isCompress = config('dbm.backup.compress', false); |
||
| 105 | $isDebug = config('dbm.backup.debug', false); |
||
| 106 | $compressBinaryPath = config('dbm.backup.compress_binary_path', ""); |
||
| 107 | $compressCommand = config('dbm.backup.compress_command', "gzip"); |
||
| 108 | $compressExtension = config('dbm.backup.compress_extension', ".gz"); |
||
| 109 | $dumpBinaryPath = config('dbm.backup.' . $driver . '.binary_path', ''); |
||
| 110 | |||
| 111 | switch ($driver) { |
||
| 112 | case 'mysql': |
||
| 113 | case 'pgsql': |
||
| 114 | if (!empty($table)) { |
||
| 115 | $dumper->setTables($table); |
||
| 116 | } |
||
| 117 | break; |
||
| 118 | case 'mongodb': |
||
| 119 | $dsn = config('dbm.backup.mongodb.dsn', ''); |
||
| 120 | if (!empty($dsn)) { |
||
| 121 | $dumper->setUri($dsn); |
||
| 122 | } |
||
| 123 | break; |
||
| 124 | |||
| 125 | } |
||
| 126 | |||
| 127 | if ($isCompress) { |
||
| 128 | $dumper->setCompressBinaryPath($compressBinaryPath); |
||
| 129 | $dumper->setCompressCommand($compressCommand); |
||
| 130 | $dumper->setCompressExtension($compressExtension); |
||
| 131 | } |
||
| 132 | if ($isDebug) { |
||
| 133 | $dumper->enableDebug(); |
||
| 134 | } |
||
| 135 | $dumper->setCommandBinaryPath($dumpBinaryPath) |
||
| 136 | ->setDestinationPath($filePath) |
||
| 137 | ->dump(); |
||
| 138 | |||
| 139 | $this->info("Backup completed"); |
||
| 140 | |||
| 141 | } catch (\Exception $e) { |
||
| 142 | |||
| 143 | throw new \Exception($e->getMessage(), 1); |
||
| 144 | |||
| 149 |
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