Completed
Pull Request — master (#140)
by
unknown
11:59 queued 08:36
created

Ftp   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 4
dl 0
loc 47
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
B getBackupFiles() 0 17 5
1
<?php
2
namespace phpbu\App\Backup\Collector;
3
4
use League\Flysystem\Filesystem;
5
use phpbu\App\Backup\Collector;
6
use phpbu\App\Backup\Target;
7
8
class Ftp extends Collector
9
{
10
    /**
11
     * @var Filesystem
12
     */
13
    private $flySystem;
14
15
    /**
16
     * @var string
17
     */
18
    private $path;
19
20
    /**
21
     * Ftp constructor.
22
     *
23
     * @param \phpbu\App\Backup\Target     $target
24
     * @param \League\Flysystem\Filesystem $flySystem
25
     */
26
    public function __construct(Target $target, Filesystem $flySystem)
27
    {
28
        $this->flySystem = $flySystem;
29
        $this->setUp($target);
30
    }
31
32
    /**
33
     * Get all created backups.
34
     *
35
     * @return \phpbu\App\Backup\File[]
36
     */
37
    public function getBackupFiles(): array
38
    {
39
        $files = $this->flySystem->listContents();
40
        foreach ($files as $file) {
41
            if ($file['type'] != 'file') {
42
                continue;
43
            }
44
            // skip currently created backup
45
            if ($file['basename'] == $this->target->getFilename()) {
46
                continue;
47
            }
48
            if ($this->isFilenameMatch($file['basename'])) {
49
                $this->files[] = new \phpbu\App\Backup\File\Ftp($this->flySystem, $file);
50
            }
51
        }
52
        return $this->files;
53
    }
54
}
55