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

DBAL/Event/SchemaAlterTableAddColumnEventArgs.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\Column;
24
use Doctrine\DBAL\Schema\TableDiff;
25
26
/**
27
 * Event Arguments used when SQL queries for adding table columns are generated inside Doctrine\DBAL\Platform\*Platform.
28
 *
29
 * @link   www.doctrine-project.org
30
 * @since  2.2
31
 * @author Jan Sorgalla <[email protected]>
32
 */
33 View Code Duplication
class SchemaAlterTableAddColumnEventArgs 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...
34
{
35
    /**
36
     * @var \Doctrine\DBAL\Schema\Column
37
     */
38
    private $_column;
39
40
    /**
41
     * @var \Doctrine\DBAL\Schema\TableDiff
42
     */
43
    private $_tableDiff;
44
45
    /**
46
     * @var \Doctrine\DBAL\Platforms\AbstractPlatform
47
     */
48
    private $_platform;
49
50
    /**
51
     * @var array
52
     */
53
    private $_sql = [];
54
55
    /**
56
     * @param \Doctrine\DBAL\Schema\Column              $column
57
     * @param \Doctrine\DBAL\Schema\TableDiff           $tableDiff
58
     * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
59
     */
60 16
    public function __construct(Column $column, TableDiff $tableDiff, AbstractPlatform $platform)
61
    {
62 16
        $this->_column    = $column;
63 16
        $this->_tableDiff = $tableDiff;
64 16
        $this->_platform  = $platform;
65 16
    }
66
67
    /**
68
     * @return \Doctrine\DBAL\Schema\Column
69
     */
70
    public function getColumn()
71
    {
72
        return $this->_column;
73
    }
74
75
    /**
76
     * @return \Doctrine\DBAL\Schema\TableDiff
77
     */
78
    public function getTableDiff()
79
    {
80
        return $this->_tableDiff;
81
    }
82
83
    /**
84
     * @return \Doctrine\DBAL\Platforms\AbstractPlatform
85
     */
86
    public function getPlatform()
87
    {
88
        return $this->_platform;
89
    }
90
91
    /**
92
     * @param string|array $sql
93
     *
94
     * @return \Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs
95
     */
96
    public function addSql($sql)
97
    {
98
        if (is_array($sql)) {
99
            $this->_sql = array_merge($this->_sql, $sql);
100
        } else {
101
            $this->_sql[] = $sql;
102
        }
103
104
        return $this;
105
    }
106
107
    /**
108
     * @return array
109
     */
110 16
    public function getSql()
111
    {
112 16
        return $this->_sql;
113
    }
114
}
115