+ /**
+ * @param string $filename File to open
+ * @return $this
+ */
+ public function open(string $filename): ParsedLogIterator
+ {
+ $this->reader->open($filename);
+ return $this;
+ }
+
+ /**
+ * @param int $limit Max num of lines to read
+ * @return $this
+ */
+ public function withLimit(int $limit): ParsedLogIterator
+ {
+ $this->limit = $limit;
+ return $this;
+ }
+
+ /**
+ * @param array $filters filters per column
+ * @return $this
+ */
+ public function withFilters(array $filters): ParsedLogIterator
+ {
+ $this->filters = $filters;
+ return $this;
+ }
+
+ /**
+ * @param string $search string to search to filter lines
+ * @return $this
+ */
+ public function withSearch(string $search): ParsedLogIterator
+ {
+ $this->search = $search;
+ return $this;
+ }
+
+ /**
+ * Check if parsed log line match filters.
+ * Always match if no filters are set.
+ *
+ * @param ParsedLogLine $parsedlogline ParsedLogLine instance
+ * @return bool Wether the parse log line matches
+ */
+ private function filter(ParsedLogLine $parsedlogline): bool
+ {
+ $match = true;
+ foreach ($this->filters as $filter => $filtervalue) {
+ switch ($filter) {
+ case "level":
+ $match = $match && ($parsedlogline->level == strtoupper($filtervalue));
+ break;
+ case "context":
+ $match = $match && ($parsedlogline->context == $filtervalue);
+ break;
+ }
+ }
+ return $match;
+ }
+
+ /**
+ * Check if parsed log line match search.
+ * Always match if no search query is set.
+ *
+ * @param ParsedLogLine $parsedlogline
+ * @return bool
+ */
+ private function search(ParsedLogLine $parsedlogline): bool
+ {
+ if ($this->search != "") {
+ return strstr($parsedlogline->logline, $this->search) !== false;
+ }
+ return true;
+ }
+
+ /**
+ * Read a line from reader and parse.
+ * Returns null if limit is reached or the reader is invalid.
+ *
+ * @param ParsedLogLine $parsedlogline
+ * @return ?ParsedLogLine
+ */
+ private function read()