| Total Complexity | 8 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Coverage | 4% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | final class DatabaseBackup implements MaintenanceHandlerInterface |
||
| 10 | { |
||
| 11 | 1 | public function __construct(private ConfigInterface $config) {} |
|
| 12 | |||
| 13 | #[Override] |
||
| 14 | public function handle(): void |
||
| 15 | { |
||
| 16 | $this->cleanup(); |
||
| 17 | $this->backup(); |
||
| 18 | } |
||
| 19 | |||
| 20 | private function cleanup(): void |
||
| 21 | { |
||
| 22 | $backup_dir = $this->config->get('db.backup_dir'); |
||
| 23 | |||
| 24 | $dir = dir($backup_dir); |
||
| 25 | if ($dir === false) { |
||
| 26 | throw new RuntimeException('error opening backup directory'); |
||
| 27 | } |
||
| 28 | while ($file = $dir->read()) { |
||
| 29 | $filename = sprintf('%s/%s', $backup_dir, $file); |
||
| 30 | |||
| 31 | if (is_file($filename) && filectime($filename) < time() - (int)$this->config->get('db.backup_cycle_time')) { |
||
| 32 | unlink($filename); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | $dir->close(); |
||
| 36 | } |
||
| 37 | |||
| 38 | private function backup(): void |
||
| 51 | } |
||
| 52 | } |
||
| 53 |
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