mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-02-02 18:08:25 +01:00
9b74cb4ee6
Summary: Ref T13395. Moves all remaining code in "libphutil/" into "arcanist/". Test Plan: Ran various arc workflows, although this probably has some remaining rough edges. Maniphest Tasks: T13395 Differential Revision: https://secure.phabricator.com/D20980
32 lines
762 B
PHP
32 lines
762 B
PHP
<?php
|
|
|
|
/**
|
|
* Example implementation and test case for @{class:PhutilBufferedIterator}.
|
|
*/
|
|
final class PhutilExampleBufferedIterator extends PhutilBufferedIterator {
|
|
|
|
private $cursor;
|
|
private $data;
|
|
|
|
protected function didRewind() {
|
|
$this->cursor = 0;
|
|
}
|
|
|
|
protected function loadPage() {
|
|
$result = $this->query($this->cursor, $this->getPageSize());
|
|
$this->cursor += count($result);
|
|
return $result;
|
|
}
|
|
|
|
public function setExampleData(array $data) {
|
|
$this->data = $data;
|
|
}
|
|
|
|
private function query($cursor, $limit) {
|
|
// NOTE: Normally you'd load or generate results from some external source
|
|
// here. Since this is an example, we just use a premade dataset.
|
|
|
|
return array_slice($this->data, $cursor, $limit);
|
|
}
|
|
|
|
}
|