Skip to content

Commit

Permalink
extract MigrationPlanCalculator interface
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Dec 28, 2019
1 parent bfd232b commit e94184f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/Doctrine/Migrations/DependencyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use Doctrine\Migrations\Version\DefaultAliasResolver;
use Doctrine\Migrations\Version\Executor;
use Doctrine\Migrations\Version\MigrationFactory;
use Doctrine\Migrations\Version\MigrationPlanCalculator;
use Doctrine\Migrations\Version\MigrationStatusCalculator;
use Doctrine\Migrations\Version\SortedMigrationPlanCalculator;
use Doctrine\ORM\EntityManagerInterface;
Expand Down Expand Up @@ -303,9 +304,9 @@ public function getMigrationStatusCalculator() : MigrationStatusCalculator
});
}

public function getMigrationPlanCalculator() : SortedMigrationPlanCalculator
public function getMigrationPlanCalculator() : MigrationPlanCalculator
{
return $this->getDependency(SortedMigrationPlanCalculator::class, function () : SortedMigrationPlanCalculator {
return $this->getDependency(SortedMigrationPlanCalculator::class, function () : MigrationPlanCalculator {
return new SortedMigrationPlanCalculator(
$this->getMigrationRepository(),
$this->getMetadataStorage()
Expand Down
18 changes: 18 additions & 0 deletions lib/Doctrine/Migrations/Version/MigrationPlanCalculator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Doctrine\Migrations\Version;

use Doctrine\Migrations\Metadata\MigrationPlanList;

/**
* The MigrationPlanCalculator is responsible for calculating the plan for migrating from the current
* version to another version.
*/
interface MigrationPlanCalculator
{
public function getPlanForExactVersion(Version $version, string $direction) : MigrationPlanList;

public function getPlanUntilVersion(?Version $to = null) : MigrationPlanList;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @internal
*/
final class SortedMigrationPlanCalculator
final class SortedMigrationPlanCalculator implements MigrationPlanCalculator
{
/** @var MigrationRepository */
private $migrationRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Doctrine\Migrations\Metadata\Storage\MetadataStorage;
use Doctrine\Migrations\MigrationRepository;
use Doctrine\Migrations\Version\Direction;
use Doctrine\Migrations\Version\MigrationPlanCalculator;
use Doctrine\Migrations\Version\SortedMigrationPlanCalculator;
use Doctrine\Migrations\Version\Version;
use PHPUnit\Framework\MockObject\MockObject;
Expand All @@ -21,7 +22,7 @@

final class MigrationPlanCalculatorTest extends TestCase
{
/** @var SortedMigrationPlanCalculator */
/** @var MigrationPlanCalculator */
private $migrationPlanCalculator;

/** @var MockObject|MigrationRepository */
Expand Down

0 comments on commit e94184f

Please sign in to comment.