Completed
Push — master ( c7757e...39cb21 )
by Luís
16s
created

Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php (1 issue)

1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
20
namespace Doctrine\DBAL\Event;
21
22
use Doctrine\DBAL\Platforms\AbstractPlatform;
23
use Doctrine\DBAL\Schema\Table;
24
25
/**
26
 * Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\AbstractPlatform.
27
 *
28
 * @link   www.doctrine-project.org
29
 * @since  2.2
30
 * @author Jan Sorgalla <[email protected]>
31
 */
32 View Code Duplication
class SchemaCreateTableEventArgs extends SchemaEventArgs
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
{
34
    /**
35
     * @var \Doctrine\DBAL\Schema\Table
36
     */
37
    private $_table;
38
39
    /**
40
     * @var array
41
     */
42
    private $_columns;
43
44
    /**
45
     * @var array
46
     */
47
    private $_options;
48
49
    /**
50
     * @var \Doctrine\DBAL\Platforms\AbstractPlatform
51
     */
52
    private $_platform;
53
54
    /**
55
     * @var array
56
     */
57
    private $_sql = [];
58
59
    /**
60
     * @param \Doctrine\DBAL\Schema\Table               $table
61
     * @param array                                     $columns
62
     * @param array                                     $options
63
     * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
64
     */
65 16
    public function __construct(Table $table, array $columns, array $options, AbstractPlatform $platform)
66
    {
67 16
        $this->_table    = $table;
68 16
        $this->_columns  = $columns;
69 16
        $this->_options  = $options;
70 16
        $this->_platform = $platform;
71 16
    }
72
73
    /**
74
     * @return \Doctrine\DBAL\Schema\Table
75
     */
76
    public function getTable()
77
    {
78
        return $this->_table;
79
    }
80
81
    /**
82
     * @return array
83
     */
84
    public function getColumns()
85
    {
86
        return $this->_columns;
87
    }
88
89
    /**
90
     * @return array
91
     */
92
    public function getOptions()
93
    {
94
        return $this->_options;
95
    }
96
97
    /**
98
     * @return \Doctrine\DBAL\Platforms\AbstractPlatform
99
     */
100
    public function getPlatform()
101
    {
102
        return $this->_platform;
103
    }
104
105
    /**
106
     * @param string|array $sql
107
     *
108
     * @return \Doctrine\DBAL\Event\SchemaCreateTableEventArgs
109
     */
110
    public function addSql($sql)
111
    {
112
        if (is_array($sql)) {
113
            $this->_sql = array_merge($this->_sql, $sql);
114
        } else {
115
            $this->_sql[] = $sql;
116
        }
117
118
        return $this;
119
    }
120
121
    /**
122
     * @return array
123
     */
124
    public function getSql()
125
    {
126
        return $this->_sql;
127
    }
128
}
129