|
| 1 | +<?php |
| 2 | +declare(strict_types=1); |
| 3 | + |
| 4 | +namespace Netlogix\Migrations\Tests\Unit\Domain\Service; |
| 5 | + |
| 6 | +use ArrayObject; |
| 7 | +use Neos\Flow\Persistence\Doctrine\Query; |
| 8 | +use Neos\Flow\Persistence\QueryInterface; |
| 9 | +use Neos\Flow\Persistence\QueryResultInterface; |
| 10 | + |
| 11 | +class ArrayQueryResult implements QueryResultInterface |
| 12 | +{ |
| 13 | + |
| 14 | + private $result; |
| 15 | + private $iterator; |
| 16 | + |
| 17 | + public function __construct(array $result) |
| 18 | + { |
| 19 | + $this->result = $result; |
| 20 | + $this->iterator = (new ArrayObject($result))->getIterator(); |
| 21 | + } |
| 22 | + |
| 23 | + public function current() |
| 24 | + { |
| 25 | + return $this->iterator->current(); |
| 26 | + } |
| 27 | + |
| 28 | + public function next() |
| 29 | + { |
| 30 | + $this->iterator->next(); |
| 31 | + } |
| 32 | + |
| 33 | + public function key() |
| 34 | + { |
| 35 | + return $this->iterator->key(); |
| 36 | + } |
| 37 | + |
| 38 | + public function valid() |
| 39 | + { |
| 40 | + return $this->iterator->valid(); |
| 41 | + } |
| 42 | + |
| 43 | + public function rewind() |
| 44 | + { |
| 45 | + $this->iterator->rewind(); |
| 46 | + } |
| 47 | + |
| 48 | + public function offsetExists($offset) |
| 49 | + { |
| 50 | + return $this->iterator->offsetExists($offset); |
| 51 | + } |
| 52 | + |
| 53 | + public function offsetGet($offset) |
| 54 | + { |
| 55 | + return $this->iterator->offsetGet($offset); |
| 56 | + } |
| 57 | + |
| 58 | + public function offsetSet($offset, $value) |
| 59 | + { |
| 60 | + $this->iterator->offsetSet($offset, $value); |
| 61 | + } |
| 62 | + |
| 63 | + public function offsetUnset($offset) |
| 64 | + { |
| 65 | + $this->iterator->offsetUnset($offset); |
| 66 | + } |
| 67 | + |
| 68 | + public function count() |
| 69 | + { |
| 70 | + return $this->iterator->count(); |
| 71 | + } |
| 72 | + |
| 73 | + public function getQuery(): QueryInterface |
| 74 | + { |
| 75 | + return new Query('foo'); |
| 76 | + } |
| 77 | + |
| 78 | + public function getFirst() |
| 79 | + { |
| 80 | + reset($this->result); |
| 81 | + |
| 82 | + return current($this->result); |
| 83 | + } |
| 84 | + |
| 85 | + public function toArray(): array |
| 86 | + { |
| 87 | + return $this->result; |
| 88 | + } |
| 89 | + |
| 90 | +} |
0 commit comments