Total Complexity | 6 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
17 | class ArrayStreamHandler implements StreamHandler |
||
18 | { |
||
19 | use ArrayAccessStreamHandlerTrait; |
||
20 | |||
21 | /** |
||
22 | * @var mixed |
||
23 | */ |
||
24 | private $data = []; |
||
25 | |||
26 | public function __construct(StreamInterface $stream) |
||
27 | { |
||
28 | $this->data[$this->fetches] = Json::decode($stream->getContents()); |
||
29 | $this->length = count($this->data[$this->fetches]['result']); |
||
30 | $this->batchSize = $this->length; |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Return the current result row |
||
35 | * |
||
36 | * @return array |
||
37 | */ |
||
38 | public function current(): array |
||
39 | { |
||
40 | return $this->data[$this->fetches]['result'][$this->position - ($this->batchSize * $this->fetches)]; |
||
41 | } |
||
42 | |||
43 | public function result(): array |
||
44 | { |
||
45 | return $this->data[$this->fetches]['result']; |
||
46 | } |
||
47 | |||
48 | public function completeResult() |
||
49 | { |
||
50 | $completeResult = [[]]; |
||
51 | |||
52 | foreach ($this->data as $result) { |
||
53 | $completeResult[] = $result['result']; |
||
54 | } |
||
55 | return array_merge(...$completeResult); |
||
56 | } |
||
57 | |||
58 | public function appendStream(StreamInterface $stream): void |
||
62 | } |
||
63 | } |
||
64 |