1 | <?php namespace Scriptotek\OaiPmh; |
||
21 | class Records extends EventEmitter implements \Iterator |
||
22 | { |
||
23 | |||
24 | // When we no longer need to support PHP 5.3: |
||
25 | // - Upgrade to Evenement 2.0 and use trait instead of extending |
||
26 | |||
27 | private $from; |
||
28 | private $until; |
||
29 | private $set; |
||
30 | private $client; |
||
31 | private $lastResponse; |
||
32 | |||
33 | private $position; |
||
34 | private $initialPosition; |
||
35 | private $resumptionToken; |
||
36 | private $initialResumptionToken; |
||
37 | |||
38 | /** @var int Total number of records in the result set. Only defined if the |
||
39 | server returns 'completeListSize', which is optional. Even if defined, the |
||
40 | value may still be only an estimate. */ |
||
41 | public $numberOfRecords = null; |
||
42 | |||
43 | private $data = array(); |
||
44 | |||
45 | /** |
||
46 | * Create a new records iterator |
||
47 | * |
||
48 | * @param string $from Start date |
||
49 | * @param string $until End date |
||
50 | * @param string $set Data set |
||
51 | * @param Client $client OAI-PMH client reference |
||
52 | * @param string $resumptionToken |
||
53 | */ |
||
54 | public function __construct($from, $until, $set, Client $client, $resumptionToken = null) |
||
69 | |||
70 | /** |
||
71 | * Return error message from last reponse, if any |
||
72 | * |
||
73 | * @return string|null |
||
74 | */ |
||
75 | public function __get($prop) |
||
81 | |||
82 | /** |
||
83 | * Return the current resumption token |
||
84 | * |
||
85 | * @return string|null |
||
86 | */ |
||
87 | public function getResumptionToken() |
||
91 | |||
92 | /** |
||
93 | * Return the last response object |
||
94 | * |
||
95 | * @return ListRecordsResponse|null |
||
96 | */ |
||
97 | public function getLastResponse() |
||
101 | |||
102 | /** |
||
103 | * Fetch more records from the service |
||
104 | */ |
||
105 | private function fetchMore() |
||
154 | |||
155 | /** |
||
156 | * Return the current element |
||
157 | * |
||
158 | * @return mixed |
||
159 | */ |
||
160 | public function current() |
||
164 | |||
165 | /** |
||
166 | * Return the key of the current element |
||
167 | * |
||
168 | * @return int |
||
169 | */ |
||
170 | public function key() |
||
174 | |||
175 | /** |
||
176 | * Rewind the Iterator to the first element |
||
177 | */ |
||
178 | public function rewind() |
||
187 | |||
188 | /** |
||
189 | * Move forward to next element |
||
190 | */ |
||
191 | public function next() |
||
206 | |||
207 | /** |
||
208 | * Check if current position is valid |
||
209 | * |
||
210 | * @return bool |
||
211 | */ |
||
212 | public function valid() |
||
216 | } |
||
217 |