1: <?php
2:
3: namespace PHPixie\ORM\Steps\Step\Query\Result;
4:
5: class Reusable extends \PHPixie\ORM\Steps\Step\Query\Result
6: implements \PHPixie\ORM\Steps\Result\Reusable
7: {
8: protected $data;
9:
10: public function asArray()
11: {
12: $this->ensureData();
13: return $this->data;
14: }
15:
16: public function getIterator()
17: {
18: $this->ensureData();
19: return new \ArrayIterator($this->data);
20: }
21:
22: public function getByOffset($offset)
23: {
24: $this->ensureData();
25: return $this->data[$offset];
26: }
27:
28: public function offsetExists($offset)
29: {
30: $this->ensureData();
31: return array_key_exists($offset, $this->data);
32: }
33:
34: protected function ensureData()
35: {
36: if ($this->data === null) {
37: $this->data = $this->result()->asArray();
38: }
39: }
40: }
41: