diff --git a/src/Config.php b/src/Config.php index f983271..0d11214 100644 --- a/src/Config.php +++ b/src/Config.php @@ -84,9 +84,9 @@ public function queriesExcludePattern(): string } /** - * Get DML pattern for queries. + * Get report pattern for queries. */ - public function queriesDmlPattern(): string + public function queriesReportPattern(): string { return $this->repository->get('sql-reporter.queries.report_pattern'); } diff --git a/src/SqlQuery.php b/src/SqlQuery.php index d711e5c..6d440d2 100644 --- a/src/SqlQuery.php +++ b/src/SqlQuery.php @@ -38,8 +38,8 @@ public function time(): float /** * Check if this query should be reported. */ - public function shouldReport(): bool + public function shouldReport(Config $config): bool { - return preg_match(config('sql-reporter.queries.report_pattern'), $this->rawQuery) === 1; + return preg_match($config->queriesReportPattern(), $this->rawQuery) === 1; } } diff --git a/src/Writer.php b/src/Writer.php index cab1008..b878f3d 100644 --- a/src/Writer.php +++ b/src/Writer.php @@ -48,7 +48,7 @@ public function writeQuery(SqlQuery $query): bool } $logLine = $this->formatter->getLine($query); $this->writeLine($logLine); - if ($query->shouldReport()) { + if ($query->shouldReport($this->config)) { $this->reportQueries[] = $logLine; } $this->loggedQueryCount++;