-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPeriodCollection.php
More file actions
55 lines (47 loc) · 1.04 KB
/
Copy pathPeriodCollection.php
File metadata and controls
55 lines (47 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* Created by PhpStorm.
* User: raph
* Date: 20/04/16
* Time: 04:37
*/
class PeriodCollection
{
/**
* @var ArchivePeriod[]
*/
protected $periods;
/**
* PeriodCollection constructor.
* @param int $start_timestamp
* @param $segments
*/
public function __construct()
{
}
public function addPeriod(ArchivePeriod $period) {
$this -> periods[]=$period;
}
public function keepFirst()
{
array_walk($this->periods,function(ArchivePeriod $period) {
$period -> keepFirst();
});
}
public function addItem(ArchiveItem $item)
{
echo "<br>additem ".$item -> getTimestamp();
$item_time = $item -> getTimestamp();
foreach($this->periods as $period) {
if($period -> hasDate($item_time)) {
$period->addItem($item);
}
}
}
public function cleanArchives()
{
foreach($this->periods as $period) {
$period -> cleanArchives();
}
}
}