-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathRecordCollection.php
More file actions
60 lines (49 loc) · 1.21 KB
/
RecordCollection.php
File metadata and controls
60 lines (49 loc) · 1.21 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
56
57
58
59
60
<?php
namespace ScriptFUSION\Porter\Collection;
/**
* Encapsulates an enumerable collection of records.
*/
abstract class RecordCollection implements \Iterator
{
private $records;
private $previousCollection;
public function __construct(\Iterator $records, self $previousCollection = null)
{
$this->records = $records;
$this->previousCollection = $previousCollection;
}
public function current()
{
return $this->records->current();
}
public function next()
{
$this->records->next();
}
public function key()
{
return $this->records->key();
}
public function valid()
{
return $this->records->valid();
}
public function rewind()
{
$this->records->rewind();
}
/**
* @return RecordCollection|null
*/
public function getPreviousCollection()
{
return $this->previousCollection;
}
public function findFirstCollection()
{
do {
$previous = isset($nextPrevious) ? $nextPrevious : $this->getPreviousCollection();
} while ($previous && $nextPrevious = $previous->getPreviousCollection());
return $previous ?: $this;
}
}