Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
Truncate | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
5 | |
100.00% |
1 / 1 |
cascade | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
render | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
3 | |||
__toString | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | /** |
3 | * Pop PHP Framework (http://www.popphp.org/) |
4 | * |
5 | * @link https://github.com/popphp/popphp-framework |
6 | * @author Nick Sagona, III <dev@nolainteractive.com> |
7 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
8 | * @license http://www.popphp.org/license New BSD License |
9 | */ |
10 | |
11 | /** |
12 | * @namespace |
13 | */ |
14 | namespace Pop\Db\Sql\Schema; |
15 | |
16 | /** |
17 | * Schema TRUNCATE table class |
18 | * |
19 | * @category Pop |
20 | * @package Pop\Db |
21 | * @author Nick Sagona, III <dev@nolainteractive.com> |
22 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
23 | * @license http://www.popphp.org/license New BSD License |
24 | * @version 6.5.0 |
25 | */ |
26 | class Truncate extends AbstractTable |
27 | { |
28 | |
29 | /** |
30 | * CASCADE flag |
31 | * @var bool |
32 | */ |
33 | protected bool $cascade = false; |
34 | |
35 | /** |
36 | * Set the CASCADE flag |
37 | * |
38 | * @return Truncate |
39 | */ |
40 | public function cascade(): Truncate |
41 | { |
42 | $this->cascade = true; |
43 | return $this; |
44 | } |
45 | |
46 | /** |
47 | * Render the table schema |
48 | * |
49 | * @return string |
50 | */ |
51 | public function render(): string |
52 | { |
53 | return 'TRUNCATE TABLE ' . $this->quoteId($this->table) . |
54 | ((($this->isPgsql()) && ($this->cascade)) ? ' CASCADE' : null) . ';' . PHP_EOL; |
55 | } |
56 | |
57 | /** |
58 | * Render the table schema to string |
59 | * |
60 | * @return string |
61 | */ |
62 | public function __toString(): string |
63 | { |
64 | return $this->render(); |
65 | } |
66 | |
67 | } |