Failed Conditions
Pull Request — develop (#3348)
by Sergei
10:40
created

SchemaIndexDefinitionEventArgs::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1.008

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
ccs 4
cts 5
cp 0.8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1.008
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL\Event;
6
7
use Doctrine\DBAL\Connection;
8
use Doctrine\DBAL\Platforms\AbstractPlatform;
9
use Doctrine\DBAL\Schema\Index;
10
11
/**
12
 * Event Arguments used when the portable index definition is generated inside Doctrine\DBAL\Schema\AbstractSchemaManager.
13
 */
14
class SchemaIndexDefinitionEventArgs extends SchemaEventArgs
15
{
16
    /** @var Index|null */
17
    private $index = null;
18
19
    /**
20
     * Raw index data as fetched from the database.
21
     *
22
     * @var mixed[]
23
     */
24
    private $tableIndex;
25
26
    /** @var string */
27
    private $table;
28
29
    /** @var Connection */
30
    private $connection;
31
32
    /**
33
     * @param mixed[] $tableIndex
34
     */
35 26
    public function __construct(array $tableIndex, string $table, Connection $connection)
36
    {
37 26
        $this->tableIndex = $tableIndex;
38 26
        $this->table      = $table;
39 26
        $this->connection = $connection;
40 26
    }
41
42
    /**
43
     * Allows to clear the index which means the index will be excluded from tables index list.
44
     */
45
    public function setIndex(?Index $index = null) : SchemaIndexDefinitionEventArgs
46
    {
47
        $this->index = $index;
48
49
        return $this;
50
    }
51
52 26
    public function getIndex() : ?Index
53
    {
54 26
        return $this->index;
55
    }
56
57
    /**
58
     * @return mixed[]
59
     */
60
    public function getTableIndex() : array
61
    {
62
        return $this->tableIndex;
63
    }
64
65
    public function getTable() : string
66
    {
67
        return $this->table;
68
    }
69
70
    public function getConnection() : Connection
71
    {
72
        return $this->connection;
73
    }
74
75
    public function getDatabasePlatform() : AbstractPlatform
76
    {
77
        return $this->connection->getDatabasePlatform();
78
    }
79
}
80