Total Complexity | 5 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class Truncate implements ITruncate |
||
10 | { |
||
11 | /** @var array<int,string|Table> */ |
||
12 | protected array $tables = []; |
||
13 | |||
14 | /** |
||
15 | * @param string|Table ...$tables |
||
16 | * |
||
17 | * @return $this |
||
18 | */ |
||
19 | 6 | public function from(string|Table ...$tables): static |
|
20 | { |
||
21 | 6 | $this->tables = array_merge($this->tables, $tables); |
|
22 | |||
23 | 6 | return $this; |
|
24 | } |
||
25 | |||
26 | /** |
||
27 | * @return string |
||
28 | */ |
||
29 | 5 | public function __toString(): string |
|
30 | { |
||
31 | 5 | if (!$this->isValid()) { |
|
32 | 1 | throw new \RuntimeException('under-initialized TRUNCATE query'); |
|
33 | } |
||
34 | |||
35 | 4 | return 'TRUNCATE ' . implode(', ', $this->tables); |
|
36 | } |
||
37 | |||
38 | 5 | public function isValid(): bool |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * @return array |
||
45 | */ |
||
46 | 1 | public function getParams(): array |
|
49 | } |
||
50 | } |
||
51 |