*/ protected CappedMemoryCache $queries; public function __construct() { $this->queries = new CappedMemoryCache(1024); } public function startQuery(string $sql, ?array $params = null, ?array $types = null): void { if ($this->activated) { $this->activeQuery = new Query($sql, $params, $types, microtime(true), $this->getStack()); } } private function getStack(): array { return debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); } public function stopQuery(): void { if ($this->activated && $this->activeQuery) { $this->activeQuery->end(microtime(true)); $this->queries[(string)$this->index] = $this->activeQuery; $this->index++; $this->activeQuery = null; } } public function getQueries(): array { return $this->queries->getData(); } public function activate(): void { $this->activated = true; } }