RunnableUpdate::prepare()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Kir\MySQL\Builder;
4
5
use Kir\MySQL\Builder\Internal\DDLPreparable;
6
use Kir\MySQL\Builder\Internal\DDLRunnable;
7
use Kir\MySQL\Builder\Traits\CreateDDLRunnable;
8
9
/**
10
 * @implements DDLPreparable<int>
11
 */
12
class RunnableUpdate extends Update implements DDLPreparable {
13
	/** @use CreateDDLRunnable<int> */
14
	use CreateDDLRunnable;
15
16
	/**
17
	 * @inheritDoc
18
	 */
19
	public function run(array $params = []): int {
20
		$query = $this->__toString();
21
22
		return $this->db()->exec($query, $params);
23
	}
24
25
	/**
26
	 * @return DDLRunnable<int>
27
	 */
28
	public function prepare(): DDLRunnable {
29
		return $this->createPreparable(
30
			$this->db()->prepare($this),
31
			fn($v) => (int) $v
32
		);
33
	}
34
}
35