Completed
Pull Request — master (#3708)
by Sergei
15:13
created

SchemaAlterTableEventArgs   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 46.15%

Importance

Changes 0
Metric Value
wmc 6
eloc 10
c 0
b 0
f 0
dl 0
loc 53
ccs 6
cts 13
cp 0.4615
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getSql() 0 3 1
A getTableDiff() 0 3 1
A getPlatform() 0 3 1
A addSql() 0 5 2
1
<?php
2
3
namespace Doctrine\DBAL\Event;
4
5
use Doctrine\DBAL\Platforms\AbstractPlatform;
6
use Doctrine\DBAL\Schema\TableDiff;
7
use function array_merge;
8
use function func_get_args;
9
use function is_array;
10
11
/**
12
 * Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\*Platform.
13
 */
14
class SchemaAlterTableEventArgs extends SchemaEventArgs
15
{
16
    /** @var TableDiff */
17
    private $tableDiff;
18
19
    /** @var AbstractPlatform */
20
    private $platform;
21
22
    /** @var string[] */
23
    private $sql = [];
24
25 486
    public function __construct(TableDiff $tableDiff, AbstractPlatform $platform)
26
    {
27 486
        $this->tableDiff = $tableDiff;
28 486
        $this->platform  = $platform;
29 486
    }
30
31
    /**
32
     * @return TableDiff
33
     */
34
    public function getTableDiff()
35
    {
36
        return $this->tableDiff;
37
    }
38
39
    /**
40
     * @return AbstractPlatform
41
     */
42
    public function getPlatform()
43
    {
44
        return $this->platform;
45
    }
46
47
    /**
48
     * Passing multiple SQL statements as an array is deprecated. Pass each statement as an individual argument instead.
49
     *
50
     * @param string|string[] $sql
51
     *
52
     * @return \Doctrine\DBAL\Event\SchemaAlterTableEventArgs
53
     */
54
    public function addSql($sql)
55
    {
56
        $this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args());
57
58
        return $this;
59
    }
60
61
    /**
62
     * @return string[]
63
     */
64 486
    public function getSql()
65
    {
66 486
        return $this->sql;
67
    }
68
}
69