1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Sandro Keil (https://sandro-keil.de) |
4
|
|
|
* |
5
|
|
|
* @link http://github.com/sandrokeil/arangodb-php-client for the canonical source repository |
6
|
|
|
* @copyright Copyright (c) 2018-2020 Sandro Keil |
7
|
|
|
* @license http://github.com/sandrokeil/arangodb-php-client/blob/master/LICENSE.md New BSD License |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
namespace ArangoDb\Statement; |
13
|
|
|
|
14
|
|
|
trait ArrayAccessStreamHandlerTrait |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* Current position in result set iteration (zero-based) |
18
|
|
|
* |
19
|
|
|
* @var int |
20
|
|
|
*/ |
21
|
|
|
private $position = 0; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Number of HTTP calls that were made to build the cursor result |
25
|
|
|
* |
26
|
|
|
* @var int |
27
|
|
|
*/ |
28
|
|
|
private $fetches = 0; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Total length of result set (in number of documents) |
32
|
|
|
* |
33
|
|
|
* @var int |
34
|
|
|
*/ |
35
|
|
|
private $length; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var int |
39
|
|
|
*/ |
40
|
|
|
private $batchSize; |
41
|
|
|
|
42
|
|
|
public function cursorId(): ?string |
43
|
|
|
{ |
44
|
|
|
return $this->data[$this->fetches]['id'] ?? null; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function hasMore(): bool |
48
|
|
|
{ |
49
|
|
|
return $this->data[$this->fetches]['hasMore'] ?? false; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function resultCount(): ?int |
53
|
|
|
{ |
54
|
|
|
return $this->data[$this->fetches]['count'] ?? null; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Get the total number of current loaded results. |
59
|
|
|
* |
60
|
|
|
* @return int Total number of laoded results |
61
|
|
|
*/ |
62
|
|
|
public function count() |
63
|
|
|
{ |
64
|
|
|
return $this->length; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function rewind(): void |
68
|
|
|
{ |
69
|
|
|
$this->position = 0; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function key(): int |
73
|
|
|
{ |
74
|
|
|
return $this->position; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function next(): void |
78
|
|
|
{ |
79
|
|
|
$this->position++; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return bool |
84
|
|
|
*/ |
85
|
|
|
public function valid(): bool |
86
|
|
|
{ |
87
|
|
|
return $this->position <= $this->length - 1; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function writesExecuted(): ?int |
91
|
|
|
{ |
92
|
|
|
return $this->data[$this->fetches]['extra']['stats']['writesExecuted'] ?? null; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function writesIgnored(): ?int |
96
|
|
|
{ |
97
|
|
|
return $this->data[$this->fetches]['extra']['stats']['writesIgnored'] ?? null; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function scannedFull(): ?int |
101
|
|
|
{ |
102
|
|
|
return $this->data[$this->fetches]['extra']['stats']['scannedFull'] ?? null; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function scannedIndex(): ?int |
106
|
|
|
{ |
107
|
|
|
return $this->data[$this->fetches]['extra']['stats']['scannedIndex'] ?? null; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function filtered(): ?int |
111
|
|
|
{ |
112
|
|
|
return $this->data[$this->fetches]['extra']['stats']['filtered'] ?? null; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function fullCount(): ?int |
116
|
|
|
{ |
117
|
|
|
return $this->data[$this->fetches]['extra']['stats']['fullCount'] ?? null; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function warnings(): array |
121
|
|
|
{ |
122
|
|
|
return $this->data[$this->fetches]['extra']['warnings'] ?? []; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function isCached(): bool |
126
|
|
|
{ |
127
|
|
|
return $this->data[$this->fetches]['cached'] ?? false; |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
|