Skip to content

Commit

Permalink
Using queriesReportPattern() from Config repository instead of direct…
Browse files Browse the repository at this point in the history
…ly accessing config
  • Loading branch information
onlime committed Mar 10, 2024
1 parent cc68f70 commit eb1e196
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
4 changes: 2 additions & 2 deletions src/SqlQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion src/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down

0 comments on commit eb1e196

Please sign in to comment.