HavingBuilder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildHavingConditions() 0 2 1
A having() 0 5 1
1
<?php
2
namespace Kir\MySQL\Builder\Traits;
3
4
use Closure;
5
use Kir\MySQL\Builder\Helpers\ConditionAddHelper;
6
use Kir\MySQL\Builder\Internal\ConditionBuilder;
7
use Kir\MySQL\Builder\Internal\Types;
8
9
/**
10
 * @phpstan-import-type DBParameterValueType from Types
11
 * @phpstan-import-type DBWhereExpressionType from Types
12
 */
13
trait HavingBuilder {
14
	use AbstractDB;
15
16
	/** @var array<int, array{DBWhereExpressionType, DBParameterValueType[]}> */
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<int, array{DBWhere...BParameterValueType[]}> at position 6 could not be parsed: Expected ':' at position 6, but found 'DBWhereExpressionType'.
Loading history...
17
	private array $having = [];
18
19
	/**
20
	 * @param DBWhereExpressionType $expression
0 ignored issues
show
Bug introduced by
The type Kir\MySQL\Builder\Traits\DBWhereExpressionType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
	 * @param DBParameterValueType ...$args
0 ignored issues
show
Bug introduced by
The type Kir\MySQL\Builder\Traits\DBParameterValueType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
	 * @return $this
23
	 */
24
	public function having($expression, ...$args) {
25
		/** @var Closure(DBWhereExpressionType, list<DBParameterValueType>):void $fn */
26
		$fn = fn($expression, $args) => $this->having[] = [$expression, $args];
27
		ConditionAddHelper::addCondition($fn, $expression, $args);
28
		return $this;
29
	}
30
31
	/**
32
	 * @param string $query
33
	 * @return string
34
	 */
35
	protected function buildHavingConditions(string $query): string {
36
		return ConditionBuilder::build($this->db(), $query, $this->having, 'HAVING');
37
	}
38
}
39