Issues (87)

src/Builder/Traits/TableBuilder.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Kir\MySQL\Builder\Traits;
4
5
use Kir\MySQL\Builder\Internal\Types;
6
7
/**
8
 * @phpstan-import-type DBTableNameType from Types
9
 */
10
trait TableBuilder {
11
	use AbstractTableNameBuilder;
12
13
	/** @var array<int, array{alias: string|null, name: DBTableNameType}> */
14
	private array $tables = [];
15
16
	/**
17
	 * @param string|null $alias
18
	 * @param DBTableNameType $table
0 ignored issues
show
The type Kir\MySQL\Builder\Traits\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...
19
	 * @return $this
20
	 */
21
	protected function addTable(?string $alias, $table) {
22
		$this->tables[] = ['alias' => $alias, 'name' => $table];
23
24
		return $this;
25
	}
26
27
	/**
28
	 * @param string $query
29
	 * @return string
30
	 */
31
	protected function buildTables(string $query): string {
32
		$arr = [];
33
		foreach($this->tables as $table) {
34
			$arr[] = "\t" . $this->buildTableName($table['alias'], $table['name']);
35
		}
36
		if(count($arr)) {
37
			$query .= implode(",\n", $arr) . "\n";
38
		}
39
40
		return $query;
41
	}
42
43
	/**
44
	 * @return array<int, array{alias: string|null, name: DBTableNameType}>
45
	 */
46
	protected function getTables(): array {
47
		return $this->tables;
48
	}
49
}
50