OptionalDBFilterMap::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Kir\MySQL\Builder\Expr;
4
5
class OptionalDBFilterMap {
6
	/**
7
	 * @param array<string, mixed> $map
8
	 */
9
	final public function __construct(
10
		private array $map,
11
	) {}
12
13
	/**
14
	 * @param array<string, mixed> $map
15
	 * @return OptionalDBFilterMap
16
	 */
17
	public static function from(array $map) {
18
		return new static($map);
19
	}
20
21
	/**
22
	 * @return array<string, mixed>
23
	 */
24
	protected function getMap(): array {
25
		return $this->map;
26
	}
27
28
	/**
29
	 * @param string $expression
30
	 * @param string|string[] $keyPath
31
	 * @param null|callable(mixed): bool $validator
32
	 * @return DBExprFilter
33
	 */
34
	public function __invoke(string $expression, $keyPath, ?callable $validator = null): DBExprFilter {
35
		return new DBExprFilter($expression, $this->map, $keyPath, $validator);
36
	}
37
}
38