OptionalDBFilterMap   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 4
c 1
b 0
f 0
dl 0
loc 31
rs 10

4 Methods

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