From e3306aa9d6181ef1a72dac0e37a90a9452bc7740 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Mon, 2 Sep 2019 17:42:45 +0200 Subject: Remove usage of reset()/each() for iterator --- it_pipe.class | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'it_pipe.class') diff --git a/it_pipe.class b/it_pipe.class index cd1b54f..e23f7e8 100644 --- a/it_pipe.class +++ b/it_pipe.class @@ -6,6 +6,7 @@ class it_pipe implements Iterator var $lines; # all lines currently in pipe var $_valid; + var $_position; /** * Creates a pipe object from input. Named arguments: @@ -50,28 +51,27 @@ function __toString() # function rewind() { - reset($this->lines); - $this->next(); + $this->_position = 0; } function next() { - $this->_valid = each($this->lines); + $this->_position++; } function valid() { - return $this->_valid; + return isset($this->lines[$this->_position]); } function current() { - return $this->_valid[1]; + return $this->lines[$this->_position]; } function key() { - return $this->_valid[0]; + return $this->_position; } -- cgit v1.2.3