Total Complexity | 8 |
Total Lines | 74 |
Duplicated Lines | 0 % |
Coverage | 95.24% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | final class IterableNewResult implements Iterator |
||
18 | { |
||
19 | /** @var AbstractHydrator */ |
||
20 | private $hydrator; |
||
21 | |||
22 | /** @var bool */ |
||
23 | private $rewinded = false; |
||
24 | |||
25 | /** @var int */ |
||
26 | private $key = -1; |
||
27 | |||
28 | /** @var object|null */ |
||
29 | private $current; |
||
30 | |||
31 | /** |
||
32 | * @param AbstractHydrator $hydrator |
||
33 | */ |
||
34 | 15 | public function __construct($hydrator) |
|
35 | { |
||
36 | 15 | $this->hydrator = $hydrator; |
|
37 | 15 | } |
|
38 | |||
39 | /** |
||
40 | * @throws HydrationException |
||
41 | */ |
||
42 | 15 | public function rewind() |
|
43 | { |
||
44 | 15 | if ($this->rewinded === true) { |
|
45 | throw new HydrationException('Can only iterate a Result once.'); |
||
46 | } |
||
47 | |||
48 | 15 | $this->current = $this->next(); |
|
|
|||
49 | 15 | $this->rewinded = true; |
|
50 | 15 | } |
|
51 | |||
52 | /** |
||
53 | * Gets the next set of results. |
||
54 | * |
||
55 | * @return mixed|false |
||
56 | */ |
||
57 | 15 | public function next() |
|
58 | { |
||
59 | 15 | $this->current = $this->hydrator->hydrateRow(); |
|
60 | 15 | if (is_array($this->current)) { |
|
61 | 14 | $this->current = array_values($this->current)[0]; |
|
62 | } |
||
63 | |||
64 | 15 | $this->key++; |
|
65 | |||
66 | 15 | return $this->current; |
|
67 | } |
||
68 | |||
69 | /** |
||
70 | * @return mixed |
||
71 | */ |
||
72 | 14 | public function current() |
|
75 | } |
||
76 | |||
77 | /** |
||
78 | * @return int |
||
79 | */ |
||
80 | 14 | public function key() |
|
81 | { |
||
82 | 14 | return $this->key; |
|
83 | } |
||
84 | |||
85 | /** |
||
86 | * @return bool |
||
87 | */ |
||
88 | 15 | public function valid() |
|
91 | } |
||
92 | } |
||
93 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..