Delete   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 25
dl 0
loc 50
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 11 1
A from() 0 9 3
1
<?php
2
namespace Kir\MySQL\Builder;
3
4
use Kir\MySQL\Builder\Internal\Types;
5
use Kir\MySQL\Builder\Traits\JoinBuilder;
6
use Kir\MySQL\Builder\Traits\LimitBuilder;
7
use Kir\MySQL\Builder\Traits\OffsetBuilder;
8
use Kir\MySQL\Builder\Traits\OrderByBuilder;
9
use Kir\MySQL\Builder\Traits\TableBuilder;
10
use Kir\MySQL\Builder\Traits\TableNameBuilder;
11
use Kir\MySQL\Builder\Traits\WhereBuilder;
12
13
/**
14
 * @phpstan-import-type DBTableNameType from Types
15
 */
16
abstract class Delete extends Statement {
17
	use TableNameBuilder;
18
	use TableBuilder;
19
	use JoinBuilder;
20
	use WhereBuilder;
21
	use OrderByBuilder;
22
	use LimitBuilder;
23
	use OffsetBuilder;
24
25
	/** @var string[] */
26
	private array $aliases = [];
27
28
	/**
29
	 * Name der Tabelle
30
	 *
31
	 * @param ($table is null ? DBTableNameType : string) $alias
0 ignored issues
show
Bug introduced by
The type Kir\MySQL\Builder\is 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...
32
	 * @param null|DBTableNameType $table
0 ignored issues
show
Bug introduced by
The type Kir\MySQL\Builder\DBTableNameType 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...
33
	 * @return $this
34
	 */
35
	public function from($alias, $table = null) {
36
		if($table !== null) {
37
			$this->aliases[] = $alias;
38
		}
39
		if($table === null) {
40
			[$alias, $table] = [$table, $alias];
41
		}
42
		$this->addTable($alias, $table);
43
		return $this;
44
	}
45
46
	/**
47
	 * @param array<string, mixed> $params
48
	 * @return int
49
	 */
50
	abstract public function run(array $params = []);
51
52
	/**
53
	 * @return string
54
	 */
55
	public function __toString(): string {
56
		$query = 'DELETE ';
57
		$query .= implode(', ', $this->aliases);
58
		$query = trim($query) . " FROM\n";
59
		$query = $this->buildTables($query);
60
		$query = $this->buildJoins($query);
61
		$query = $this->buildWhereConditions($query);
62
		$query = $this->buildOrder($query);
63
		$query = $this->buildLimit($query);
64
		$query = $this->buildOffset($query);
65
		return $query;
66
	}
67
}
68