Completed
Push — master ( 953aec...166410 )
by Sebastian
13s
created

YandexDisk::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
namespace phpbu\App\Backup\Collector;
4
5
use Arhitector\Yandex\Disk;
6
use phpbu\App\Backup\Collector;
7
use phpbu\App\Backup\File;
8
use phpbu\App\Backup\Path;
9
use phpbu\App\Backup\Target;
10
11
/**
12
 * YandexDisk class.
13
 *
14
 * @package    phpbu
15
 * @subpackage Backup
16
 * @author     Sebastian Feldmann <[email protected]>
17
 * @author     Alexander Palchikov AxelPAL <[email protected]>
18
 * @copyright  Sebastian Feldmann <[email protected]>
19
 * @license    https://opensource.org/licenses/MIT The MIT License (MIT)
20
 * @link       http://phpbu.de/
21
 */
22
class YandexDisk extends Remote implements Collector
23
{
24
    /**
25
     * @var Disk
26
     */
27
    protected $disk;
28
29
    /**
30
     * OpenStack constructor.
31
     *
32
     * @param Target $target
33
     * @param Path $path
34
     * @param Disk $disk
35
     */
36 2
    public function __construct(Target $target, Path $path, Disk $disk)
37
    {
38 2
        $this->setUp($target, $path);
39 2
        $this->disk = $disk;
40 2
    }
41
42
    /**
43
     * Collect all created backups.
44
     */
45 2
    protected function collectBackups()
46
    {
47 2
        $items = $this->disk->getResource($this->path->getPathThatIsNotChanging());
48 2 View Code Duplication
        foreach ($items->toArray()['items'] as $item) {
49 2
            if (($item instanceof Disk\Resource\Closed) && $this->isFileMatch($item->getPath())) {
50 2
                $file = new File\YandexDisk($this->disk, $item);
51 2
                $index = $this->getFileIndex($file);
52 2
                $this->files[$index] = $file;
53
            }
54
        }
55 2
    }
56
}
57