|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of the Backup package, an RunOpenCode project. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) 2015 RunOpenCode |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
* |
|
10
|
|
|
* This project is fork of "kbond/php-backup", for full credits info, please |
|
11
|
|
|
* view CREDITS file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
namespace RunOpenCode\Backup\Destination; |
|
14
|
|
|
|
|
15
|
|
|
use RunOpenCode\Backup\Contract\BackupInterface; |
|
16
|
|
|
use RunOpenCode\Backup\Contract\DestinationInterface; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class DestinationCollection |
|
20
|
|
|
* |
|
21
|
|
|
* Collection of destinations enables you to backup on several different destinations at once. |
|
22
|
|
|
* |
|
23
|
|
|
* @package RunOpenCode\Backup\Destination |
|
24
|
|
|
*/ |
|
25
|
|
|
final class DestinationCollection implements DestinationInterface |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* @var DestinationInterface[] |
|
29
|
|
|
*/ |
|
30
|
|
|
private $destinations; |
|
31
|
|
|
|
|
32
|
4 |
|
public function __construct(array $destinations = array()) |
|
33
|
|
|
{ |
|
34
|
4 |
|
$this->destinations = array(); |
|
35
|
|
|
|
|
36
|
4 |
|
foreach ($destinations as $destination) { |
|
37
|
2 |
|
$this->addDestination($destination); |
|
38
|
2 |
|
} |
|
39
|
4 |
|
} |
|
40
|
|
|
|
|
41
|
4 |
|
public function addDestination(DestinationInterface $destination) |
|
42
|
|
|
{ |
|
43
|
4 |
|
$this->destinations[] = $destination; |
|
44
|
4 |
|
return $this; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* {@inheritdoc} |
|
49
|
|
|
*/ |
|
50
|
4 |
|
public function push(BackupInterface $backup) |
|
51
|
|
|
{ |
|
52
|
4 |
|
foreach ($this->destinations as $destination) { |
|
53
|
4 |
|
$destination->push($backup); |
|
54
|
2 |
|
} |
|
55
|
2 |
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* {@inheritdoc} |
|
59
|
|
|
*/ |
|
60
|
|
|
public function get($name) |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->destinations[0]->get($name); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* {@inheritdoc} |
|
67
|
|
|
*/ |
|
68
|
|
|
public function has($name) |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->destinations[0]->has($name); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* {@inheritdoc} |
|
75
|
|
|
*/ |
|
76
|
|
|
public function delete($name) |
|
77
|
|
|
{ |
|
78
|
|
|
foreach ($this->destinations as $destination) { |
|
79
|
|
|
$destination->delete($name); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* {@inheritdoc} |
|
85
|
|
|
*/ |
|
86
|
|
|
public function all() |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->destinations[0]->all(); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* {@inheritdoc} |
|
93
|
|
|
*/ |
|
94
|
|
|
public function getIterator() |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->destinations[0]->getIterator(); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* {@inheritdoc} |
|
101
|
|
|
*/ |
|
102
|
|
|
public function count() |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->destinations[0]->count(); |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
|