diff options
Diffstat (limited to 'vendor/doctrine/dbal/src/Schema/SchemaDiff.php')
-rw-r--r-- | vendor/doctrine/dbal/src/Schema/SchemaDiff.php | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/vendor/doctrine/dbal/src/Schema/SchemaDiff.php b/vendor/doctrine/dbal/src/Schema/SchemaDiff.php new file mode 100644 index 0000000..28c014d --- /dev/null +++ b/vendor/doctrine/dbal/src/Schema/SchemaDiff.php | |||
@@ -0,0 +1,109 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\DBAL\Schema; | ||
6 | |||
7 | use function array_filter; | ||
8 | use function count; | ||
9 | |||
10 | /** | ||
11 | * Differences between two schemas. | ||
12 | */ | ||
13 | class SchemaDiff | ||
14 | { | ||
15 | /** @var array<TableDiff> */ | ||
16 | private readonly array $alteredTables; | ||
17 | |||
18 | /** | ||
19 | * Constructs an SchemaDiff object. | ||
20 | * | ||
21 | * @internal The diff can be only instantiated by a {@see Comparator}. | ||
22 | * | ||
23 | * @param array<string> $createdSchemas | ||
24 | * @param array<string> $droppedSchemas | ||
25 | * @param array<Table> $createdTables | ||
26 | * @param array<TableDiff> $alteredTables | ||
27 | * @param array<Table> $droppedTables | ||
28 | * @param array<Sequence> $createdSequences | ||
29 | * @param array<Sequence> $alteredSequences | ||
30 | * @param array<Sequence> $droppedSequences | ||
31 | */ | ||
32 | public function __construct( | ||
33 | private readonly array $createdSchemas, | ||
34 | private readonly array $droppedSchemas, | ||
35 | private readonly array $createdTables, | ||
36 | array $alteredTables, | ||
37 | private readonly array $droppedTables, | ||
38 | private readonly array $createdSequences, | ||
39 | private readonly array $alteredSequences, | ||
40 | private readonly array $droppedSequences, | ||
41 | ) { | ||
42 | $this->alteredTables = array_filter($alteredTables, static function (TableDiff $diff): bool { | ||
43 | return ! $diff->isEmpty(); | ||
44 | }); | ||
45 | } | ||
46 | |||
47 | /** @return array<string> */ | ||
48 | public function getCreatedSchemas(): array | ||
49 | { | ||
50 | return $this->createdSchemas; | ||
51 | } | ||
52 | |||
53 | /** @return array<string> */ | ||
54 | public function getDroppedSchemas(): array | ||
55 | { | ||
56 | return $this->droppedSchemas; | ||
57 | } | ||
58 | |||
59 | /** @return array<Table> */ | ||
60 | public function getCreatedTables(): array | ||
61 | { | ||
62 | return $this->createdTables; | ||
63 | } | ||
64 | |||
65 | /** @return array<TableDiff> */ | ||
66 | public function getAlteredTables(): array | ||
67 | { | ||
68 | return $this->alteredTables; | ||
69 | } | ||
70 | |||
71 | /** @return array<Table> */ | ||
72 | public function getDroppedTables(): array | ||
73 | { | ||
74 | return $this->droppedTables; | ||
75 | } | ||
76 | |||
77 | /** @return array<Sequence> */ | ||
78 | public function getCreatedSequences(): array | ||
79 | { | ||
80 | return $this->createdSequences; | ||
81 | } | ||
82 | |||
83 | /** @return array<Sequence> */ | ||
84 | public function getAlteredSequences(): array | ||
85 | { | ||
86 | return $this->alteredSequences; | ||
87 | } | ||
88 | |||
89 | /** @return array<Sequence> */ | ||
90 | public function getDroppedSequences(): array | ||
91 | { | ||
92 | return $this->droppedSequences; | ||
93 | } | ||
94 | |||
95 | /** | ||
96 | * Returns whether the diff is empty (contains no changes). | ||
97 | */ | ||
98 | public function isEmpty(): bool | ||
99 | { | ||
100 | return count($this->createdSchemas) === 0 | ||
101 | && count($this->droppedSchemas) === 0 | ||
102 | && count($this->createdTables) === 0 | ||
103 | && count($this->alteredTables) === 0 | ||
104 | && count($this->droppedTables) === 0 | ||
105 | && count($this->createdSequences) === 0 | ||
106 | && count($this->alteredSequences) === 0 | ||
107 | && count($this->droppedSequences) === 0; | ||
108 | } | ||
109 | } | ||