Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
Drop
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
4 / 4
8
100.00% covered (success)
100.00%
1 / 1
 ifExists
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 cascade
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 render
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
5
 __toString
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
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 */
14namespace Pop\Db\Sql\Schema;
15
16/**
17 * Schema DROP 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 */
26class Drop extends AbstractTable
27{
28
29    /**
30     * IF EXISTS flag
31     * @var bool
32     */
33    protected bool $ifExists = false;
34
35    /**
36     * CASCADE flag
37     * @var bool
38     */
39    protected bool $cascade  = false;
40
41    /**
42     * Set the IF EXISTS flag
43     *
44     * @return Drop
45     */
46    public function ifExists(): Drop
47    {
48        $this->ifExists = true;
49        return $this;
50    }
51
52    /**
53     * Set the CASCADE flag
54     *
55     * @return Drop
56     */
57    public function cascade(): Drop
58    {
59        $this->cascade = true;
60        return $this;
61    }
62
63    /**
64     * Render the table schema
65     *
66     * @return string
67     */
68    public function render(): string
69    {
70        return 'DROP TABLE ' . ((($this->ifExists) && ($this->dbType != self::SQLSRV)) ? 'IF EXISTS ' : null)
71            . $this->quoteId($this->table) . ((($this->isPgsql()) && ($this->cascade)) ? ' CASCADE' : null) . ';' . PHP_EOL;
72    }
73
74    /**
75     * Render the table schema to string
76     *
77     * @return string
78     */
79    public function __toString(): string
80    {
81        return $this->render();
82    }
83
84}