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