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
Rename
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
4 / 4
5
100.00% covered (success)
100.00%
1 / 1
 to
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getTo
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 render
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 __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 RENAME 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 Rename extends AbstractTable
27{
28
29    /**
30     * Rename table name
31     * @var ?string
32     */
33    protected ?string $to = null;
34
35    /**
36     * Set the rename table name
37     *
38     * @param  string $table
39     * @return Rename
40     */
41    public function to(string $table): Rename
42    {
43        $this->to = $table;
44        return $this;
45    }
46
47    /**
48     * Get the rename table name
49     *
50     * @return string
51     */
52    public function getTo(): string
53    {
54        return $this->to;
55    }
56
57    /**
58     * Render the table schema
59     *
60     * @return string
61     */
62    public function render(): string
63    {
64        return ($this->isMysql()) ?
65            'RENAME TABLE ' . $this->quoteId($this->table) . ' TO ' . $this->quoteId($this->to) . ';' . PHP_EOL :
66            'ALTER TABLE ' . $this->quoteId($this->table) . ' RENAME TO ' . $this->quoteId($this->to) . ';' . PHP_EOL;
67    }
68
69    /**
70     * Render the table schema to string
71     *
72     * @return string
73     */
74    public function __toString(): string
75    {
76        return $this->render();
77    }
78
79}