Skip to content

Commit c41fbf3

Browse files
authored
Merge pull request #38 from redthor/fix/configuration-mess-report
Fix/configuration mess report
2 parents 0607e7e + ae5350c commit c41fbf3

18 files changed

+432
-369
lines changed

src/AntiMattr/MongoDB/Migrations/Collection/Statistics.php

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,18 @@ protected function getCollectionStats()
118118
$database = $this->collection->getDatabase();
119119
$name = $this->collection->getName();
120120

121-
try {
122-
if (!$data = $database->command(['collStats' => $name])) {
123-
$message = sprintf(
124-
'Statistics not found for collection %s',
125-
$name
126-
);
127-
throw new Exception($message);
128-
}
129-
if (isset($data['errmsg'])) {
130-
throw new Exception($data['errmsg']);
131-
}
121+
if (!$data = $database->command(['collStats' => $name])) {
122+
$message = sprintf(
123+
'Statistics not found for collection %s',
124+
$name
125+
);
126+
throw new Exception($message);
127+
}
132128

133-
return $data;
134-
} catch (Exception $e) {
135-
throw $e;
129+
if (isset($data['errmsg'])) {
130+
throw new Exception($data['errmsg']);
136131
}
137132

138-
return [];
133+
return $data;
139134
}
140135
}

src/AntiMattr/MongoDB/Migrations/Configuration/AbstractFileConfiguration.php

Lines changed: 0 additions & 80 deletions
This file was deleted.

src/AntiMattr/MongoDB/Migrations/Configuration/Configuration.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ class Configuration
103103
*/
104104
private $outputWriter;
105105

106+
/**
107+
* @var string
108+
*/
109+
private $file;
110+
106111
/**
107112
* @param \Doctrine\MongoDB\Connection $connection
108113
* @param \AntiMattr\MongoDB\Migrations\OutputWriter $outputWriter
@@ -202,6 +207,8 @@ public function getMigrations()
202207
public function setMigrationsDatabaseName($databaseName)
203208
{
204209
$this->migrationsDatabaseName = $databaseName;
210+
211+
return $this;
205212
}
206213

207214
/**
@@ -218,6 +225,8 @@ public function getMigrationsDatabaseName()
218225
public function setMigrationsCollectionName($collectionName)
219226
{
220227
$this->migrationsCollectionName = $collectionName;
228+
229+
return $this;
221230
}
222231

223232
/**
@@ -234,6 +243,8 @@ public function getMigrationsCollectionName()
234243
public function setMigrationsDirectory($migrationsDirectory)
235244
{
236245
$this->migrationsDirectory = $migrationsDirectory;
246+
247+
return $this;
237248
}
238249

239250
/**
@@ -252,6 +263,8 @@ public function getMigrationsDirectory()
252263
public function setMigrationsNamespace($migrationsNamespace)
253264
{
254265
$this->migrationsNamespace = $migrationsNamespace;
266+
267+
return $this;
255268
}
256269

257270
/**
@@ -268,6 +281,8 @@ public function getMigrationsNamespace()
268281
public function setMigrationsScriptDirectory($scriptsDirectory)
269282
{
270283
$this->migrationsScriptDirectory = $scriptsDirectory;
284+
285+
return $this;
271286
}
272287

273288
/**
@@ -278,6 +293,24 @@ public function getMigrationsScriptDirectory()
278293
return $this->migrationsScriptDirectory;
279294
}
280295

296+
/**
297+
* @param string $file
298+
*/
299+
public function setFile($file)
300+
{
301+
$this->file = $file;
302+
303+
return $this;
304+
}
305+
306+
/**
307+
* @return string|null
308+
*/
309+
public function getFile(): ?string
310+
{
311+
return $this->file;
312+
}
313+
281314
/**
282315
* Returns all migrated versions from the versions collection, in an array.
283316
*
@@ -348,6 +381,8 @@ public function getUnavailableMigratedVersions()
348381
public function setName($name)
349382
{
350383
$this->name = $name;
384+
385+
return $this;
351386
}
352387

353388
/**

0 commit comments

Comments
 (0)