ClosureQueryLogger::log()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 2
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Kir\MySQL\QueryLogger;
4
5
use Throwable;
6
7
class ClosureQueryLogger implements QueryLogger {
8
	/** @var callable(string, float, string, Throwable|null): void */
9
	private $fn;
10
11
	/**
12
	 * @param callable(string, float, string, Throwable|null):void $fn
13
	 */
14
	public function __construct(callable $fn) {
15
		$this->fn = $fn;
16
	}
17
18
	/**
19
	 * @inheritDoc
20
	 */
21
	public function log(string $query, float $duration): void {
22
		call_user_func($this->fn, $query, $duration, 'INFO', null);
23
	}
24
25
	/**
26
	 * @inheritDoc
27
	 */
28
	public function logError(string $query, Throwable $exception, float $duration): void {
29
		call_user_func($this->fn, $query, $duration, 'ERROR', $exception);
30
	}
31
}
32