Truncate::getParams()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace QB\Generic\Statement;
6
7
use QB\Generic\Clause\Table;
8
use RuntimeException;
9
10
class Truncate implements ITruncate
11
{
12
    /** @var array<int,Table|string> */
13
    protected array $tables = [];
14
15
    /**
16
     * @param Table|string ...$tables
17
     *
18
     * @return $this
19
     */
20 6
    public function from(Table|string ...$tables): static
21
    {
22 6
        $this->tables = array_merge($this->tables, $tables);
23
24 6
        return $this;
25
    }
26
27
    /**
28
     * @return string
29
     */
30 5
    public function __toString(): string
31
    {
32 5
        if (!$this->isValid()) {
33 1
            throw new RuntimeException('under-initialized TRUNCATE query');
34
        }
35
36 4
        return 'TRUNCATE ' . implode(', ', $this->tables);
37
    }
38
39 5
    public function isValid(): bool
40
    {
41 5
        return count($this->tables) > 0;
42
    }
43
44
    /**
45
     * @return array
46
     */
47 1
    public function getParams(): array
48
    {
49 1
        return [];
50
    }
51
}
52