From 2ef54746f428f0efe959a9bdeb11294aa8872d2f Mon Sep 17 00:00:00 2001 From: Robert Gruendler Date: Thu, 21 May 2015 18:25:17 +0200 Subject: [PATCH] fixed arrayaccess implementation --- src/Dubture/Monolog/Reader/LogReader.php | 2 +- tests/Dubture/Monolog/Reader/Test/LogReaderTest.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Dubture/Monolog/Reader/LogReader.php b/src/Dubture/Monolog/Reader/LogReader.php index 6084596..c20deb6 100644 --- a/src/Dubture/Monolog/Reader/LogReader.php +++ b/src/Dubture/Monolog/Reader/LogReader.php @@ -69,7 +69,7 @@ public function setParser(LogParserInterface $parser) */ public function offsetExists($offset) { - return $this->lineCount >= $offset; + return $offset < $this->lineCount; } /** diff --git a/tests/Dubture/Monolog/Reader/Test/LogReaderTest.php b/tests/Dubture/Monolog/Reader/Test/LogReaderTest.php index 8938177..8b22e4c 100644 --- a/tests/Dubture/Monolog/Reader/Test/LogReaderTest.php +++ b/tests/Dubture/Monolog/Reader/Test/LogReaderTest.php @@ -45,11 +45,18 @@ public function testReader() public function testIterator() { + // the test.log file contains 2 log lines $file = __DIR__ . '/../../../../files/test.log'; $reader = new LogReader($file); $lines = array(); $keys = array(); + $this->assertTrue($reader->offsetExists(0)); + $this->assertTrue($reader->offsetExists(1)); + + $this->assertFalse($reader->offsetExists(2)); + $this->assertFalse($reader->offsetExists(3)); + $this->assertEquals(2, count($reader)); foreach ($reader as $i => $log) {