|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace MySQLReplication\Repository; |
|
5
|
|
|
|
|
6
|
|
|
class FieldDTO |
|
7
|
|
|
{ |
|
8
|
|
|
private $columnName; |
|
9
|
|
|
private $collationName; |
|
10
|
|
|
private $characterSetName; |
|
11
|
|
|
private $columnComment; |
|
12
|
|
|
private $columnType; |
|
13
|
|
|
private $columnKey; |
|
14
|
|
|
|
|
15
|
54 |
|
public function __construct( |
|
16
|
|
|
string $columnName, |
|
17
|
|
|
?string $collationName, |
|
18
|
|
|
?string $characterSetName, |
|
19
|
|
|
string $columnComment, |
|
20
|
|
|
string $columnType, |
|
21
|
|
|
string $columnKey |
|
22
|
|
|
) { |
|
23
|
54 |
|
$this->columnName = $columnName; |
|
24
|
54 |
|
$this->collationName = $collationName; |
|
25
|
54 |
|
$this->characterSetName = $characterSetName; |
|
26
|
54 |
|
$this->columnComment = $columnComment; |
|
27
|
54 |
|
$this->columnType = $columnType; |
|
28
|
54 |
|
$this->columnKey = $columnKey; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
1 |
|
public static function makeDummy(int $index): self |
|
32
|
|
|
{ |
|
33
|
1 |
|
return self::makeFromArray( |
|
34
|
1 |
|
[ |
|
35
|
1 |
|
'COLUMN_NAME' => 'DROPPED_COLUMN_' . $index, |
|
36
|
1 |
|
'COLLATION_NAME' => null, |
|
37
|
1 |
|
'CHARACTER_SET_NAME' => null, |
|
38
|
1 |
|
'COLUMN_COMMENT' => '', |
|
39
|
1 |
|
'COLUMN_TYPE' => 'BLOB', |
|
40
|
1 |
|
'COLUMN_KEY' => '' |
|
41
|
1 |
|
] |
|
42
|
1 |
|
); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
54 |
|
public static function makeFromArray(array $field): self |
|
46
|
|
|
{ |
|
47
|
54 |
|
return new self( |
|
48
|
54 |
|
$field['COLUMN_NAME'], |
|
49
|
54 |
|
$field['COLLATION_NAME'], |
|
50
|
54 |
|
$field['CHARACTER_SET_NAME'], |
|
51
|
54 |
|
$field['COLUMN_COMMENT'], |
|
52
|
54 |
|
$field['COLUMN_TYPE'], |
|
53
|
54 |
|
$field['COLUMN_KEY'] |
|
54
|
54 |
|
); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
52 |
|
public function getColumnName(): string |
|
58
|
|
|
{ |
|
59
|
52 |
|
return $this->columnName; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function getCollationName(): ?string |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->collationName; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function getCharacterSetName(): ?string |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->characterSetName; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function getColumnComment(): string |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->columnComment; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
20 |
|
public function getColumnType(): string |
|
78
|
|
|
{ |
|
79
|
20 |
|
return $this->columnType; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function getColumnKey(): string |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->columnKey; |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|