1 | <?php |
||
9 | final class QueryResult |
||
10 | { |
||
11 | /** @var string */ |
||
12 | private $id; |
||
13 | |||
14 | /** @var string */ |
||
15 | private $infoUri; |
||
16 | |||
17 | /** @var string */ |
||
18 | private $partialCancelUri; |
||
19 | |||
20 | /** @var string */ |
||
21 | private $nextUri; |
||
22 | |||
23 | /** @var \stdClass[] */ |
||
24 | private $columns = []; |
||
25 | |||
26 | /** @var array */ |
||
27 | private $data = []; |
||
28 | |||
29 | /** @var StatementStats|null */ |
||
30 | private $stats; |
||
31 | |||
32 | /** @var QueryError|null */ |
||
33 | private $error; |
||
34 | |||
35 | /** |
||
36 | * QueryResult constructor. |
||
37 | * |
||
38 | * @param string $content |
||
39 | */ |
||
40 | public function set(string $content) |
||
55 | |||
56 | /** |
||
57 | * @return string|null |
||
58 | */ |
||
59 | public function getId() |
||
63 | |||
64 | /** |
||
65 | * @return string|null |
||
66 | */ |
||
67 | public function getInfoUri() |
||
71 | |||
72 | /** |
||
73 | * @return string|null |
||
74 | */ |
||
75 | public function getNextUri() |
||
79 | |||
80 | /** |
||
81 | * @return QueryError|null |
||
82 | */ |
||
83 | public function getError() |
||
87 | |||
88 | /** |
||
89 | * @return string|null |
||
90 | */ |
||
91 | public function getPartialCancelUri() |
||
95 | |||
96 | /** |
||
97 | * @return \Generator |
||
98 | */ |
||
99 | public function getData(): \Generator |
||
113 | |||
114 | /** |
||
115 | * @param string $content |
||
116 | * |
||
117 | * @return \stdClass |
||
118 | */ |
||
119 | private function parseContent(string $content): \stdClass |
||
128 | |||
129 | /** |
||
130 | * @param \stdClass $jsonContent |
||
131 | * |
||
132 | * @return StatementStats |
||
133 | */ |
||
134 | private function statsTransfer(\stdClass $jsonContent): StatementStats |
||
138 | |||
139 | /** |
||
140 | * @param \stdClass $jsonContent |
||
141 | * |
||
142 | * @return QueryError |
||
143 | */ |
||
144 | private function errorTransfer(\stdClass $jsonContent): QueryError |
||
148 | |||
149 | /** |
||
150 | * @param array $columns |
||
151 | */ |
||
152 | private function columnTransfer(array $columns) |
||
158 | |||
159 | /** |
||
160 | * @return StatementStats|null |
||
161 | */ |
||
162 | public function getStats() |
||
166 | |||
167 | /** |
||
168 | * @return Column[] |
||
169 | */ |
||
170 | public function getColumns(): array |
||
174 | } |
||
175 |
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: