Completed
Push — master ( d82b6a...0d953e )
by Marco
45:18 queued 42:00
created

SchemaAlterTableChangeColumnEventArgs::addSql()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
ccs 0
cts 3
cp 0
rs 10
cc 2
nc 1
nop 1
crap 6
1
<?php
2
3
namespace Doctrine\DBAL\Event;
4
5
use Doctrine\DBAL\Platforms\AbstractPlatform;
6
use Doctrine\DBAL\Schema\ColumnDiff;
7
use Doctrine\DBAL\Schema\TableDiff;
8
use function array_merge;
9
use function func_get_args;
10
use function is_array;
11
12
/**
13
 * Event Arguments used when SQL queries for changing table columns are generated inside Doctrine\DBAL\Platform\*Platform.
14
 */
15
class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs
16
{
17
    /** @var ColumnDiff */
18
    private $columnDiff;
19
20
    /** @var TableDiff */
21
    private $tableDiff;
22
23
    /** @var AbstractPlatform */
24
    private $platform;
25
26
    /** @var string[] */
27
    private $sql = [];
28
29 486
    public function __construct(ColumnDiff $columnDiff, TableDiff $tableDiff, AbstractPlatform $platform)
30
    {
31 486
        $this->columnDiff = $columnDiff;
32 486
        $this->tableDiff  = $tableDiff;
33 486
        $this->platform   = $platform;
34 486
    }
35
36
    /**
37
     * @return ColumnDiff
38
     */
39
    public function getColumnDiff()
40
    {
41
        return $this->columnDiff;
42
    }
43
44
    /**
45
     * @return TableDiff
46
     */
47
    public function getTableDiff()
48
    {
49
        return $this->tableDiff;
50
    }
51
52
    /**
53
     * @return AbstractPlatform
54
     */
55
    public function getPlatform()
56
    {
57
        return $this->platform;
58
    }
59
60
    /**
61
     * Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead.
62
     *
63
     * @param string|string[] $sql
64
     *
65
     * @return \Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs
66
     */
67
    public function addSql($sql)
68
    {
69
        $this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args());
70
71
        return $this;
72
    }
73
74
    /**
75
     * @return string[]
76
     */
77 486
    public function getSql()
78
    {
79 486
        return $this->sql;
80
    }
81
}
82