diff --git a/src/Db/OdbcResultSet.php b/src/Db/OdbcResultSet.php index a622632..a05e47a 100644 --- a/src/Db/OdbcResultSet.php +++ b/src/Db/OdbcResultSet.php @@ -25,10 +25,6 @@ class OdbcResultSet implements \Iterator, \ArrayAccess, \Countable return $this->num_rows; } - public function count() { - return $this->get_num_rows(); - } - public function is_error() { return ($this->error ? true : false); @@ -49,78 +45,55 @@ class OdbcResultSet implements \Iterator, \ArrayAccess, \Countable return $this->results; } - // ArrayAccess - /** - * @param int $offset - * @return bool - */ - public function offsetExists($offset) - { - return !$this->error && $this->cursor_index < $this->length && $this->cursor_index >= 0; + // Implementing Countable + public function count(): int { + return $this->get_num_rows(); } - /** - * @param int $offset - * @return bool|array - */ - public function offsetGet($offset) + // Implementing ArrayAccess + public function offsetExists(mixed $offset): bool + { + return !$this->error && $offset < $this->length && $offset >= 0; + } + + public function offsetGet(mixed $offset): mixed { return $this->offsetExists($offset) ? $this->results[$offset] : false; } - public function offsetSet($offset, $value) + public function offsetSet(mixed $offset, mixed $value): void { if($this->offsetExists($offset)) { $this->results[$offset] = $value; } } - public function offsetUnset($offset) + public function offsetUnset(mixed $offset): void { - throw new \RuntimeException("This makes no sense at all."); + throw new \RuntimeException("Unsetting elements is not supported."); } - // Iterator - /** - * Return the current element - * @return mixed - */ - public function current() + // Implementing Iterator + public function current(): mixed { return $this->offsetGet($this->cursor_index); } - /** - * Return the key of the current element - * @return mixed - */ public function key(): mixed { return $this->cursor_index; } - /** - * Move forward to next element - * @return void - */ public function next(): void { ++$this->cursor_index; } - /** - * Rewind the Iterator to the first element - * @return void - */ public function rewind(): void { $this->cursor_index = 0; } - /** - * Checks if current position is valid - * @return bool - */ public function valid(): bool { return $this->offsetExists($this->cursor_index);