Completed
Push — master ( ecbf0c...c8753a )
by Ron
02:19
created

HavingBuilder::having()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 2
1
<?php
2
namespace Kir\MySQL\Builder\Traits;
3
4
use Kir\MySQL\Builder\Expr\OptionalExpression;
5
use Kir\MySQL\Builder\Internal\ConditionBuilder;
6
7
trait HavingBuilder {
8
	use AbstractDB;
9
	use ConditionDefinition;
10
11
	/** @var array[] */
12
	private $having = [];
13
14
	/**
15
	 * @param string|array|object|OptionalExpression $expression
16
	 * @param mixed[] $args
17
	 * @return $this
18
	 */
19
	public function having($expression, ...$args) {
20
		$fn = function (...$args) { $this->having[] = $args; };
21
		return $this->addCondition($fn, $expression, ...$args);
22
	}
23
24
	/**
25
	 * @param string $query
26
	 * @return string
27
	 */
28
	protected function buildHavingConditions($query) {
29
		return ConditionBuilder::build($this->db(), $query, $this->having, 'HAVING');
30
	}
31
}
32