From 52c1d98bebb4ec561e263386bd2f6b6999135309 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Fri, 5 Sep 2014 12:03:59 +0200 Subject: [PATCH] Icinga\Protocol\File\FileReader: use Icinga\Util\Enumerate --- library/Icinga/Protocol/File/FileReader.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/Icinga/Protocol/File/FileReader.php b/library/Icinga/Protocol/File/FileReader.php index e66c3edf5..2551489bf 100644 --- a/library/Icinga/Protocol/File/FileReader.php +++ b/library/Icinga/Protocol/File/FileReader.php @@ -6,6 +6,7 @@ namespace Icinga\Protocol\File; use Icinga\Data\Selectable; use Countable; +use Icinga\Util\Enumerate; use Zend_Config; /** @@ -52,7 +53,9 @@ class FileReader implements Selectable, Countable */ public function iterate() { - return new FileIterator($this->filename, $this->fields); + return new Enumerate( + new FileIterator($this->filename, $this->fields) + ); } /** @@ -117,15 +120,13 @@ class FileReader implements Selectable, Countable $skip = $count - ($skip + $read); } } - $index = 0; - foreach ($this->iterate() as $line) { + foreach ($this->iterate() as $index => $line) { if ($index >= $skip) { if ($index >= $skip + $read) { break; } $lines[] = $line; } - ++$index; } if ($query->sortDesc()) { $lines = array_reverse($lines);