mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
33 lines
678 B
PHP
33 lines
678 B
PHP
<?php
|
|
|
|
namespace Chill\MainBundle\Doctrine\Migrations;
|
|
|
|
use Doctrine\Migrations\Version\Comparator;
|
|
use Doctrine\Migrations\Version\Version;
|
|
|
|
use function strcmp;
|
|
use function explode;
|
|
|
|
/**
|
|
* Compare Version classes names from different namespaces and order them.
|
|
*
|
|
* Version are compared on the date's class.
|
|
*/
|
|
final class VersionComparator implements Comparator
|
|
{
|
|
private function getNumber(Version $version): string
|
|
{
|
|
$names = explode("\\", (string) $version);
|
|
|
|
return end($names);
|
|
}
|
|
|
|
public function compare(Version $a, Version $b): int
|
|
{
|
|
$q = strcmp($this->getNumber($a), $this->getNumber($b));
|
|
|
|
return $q;
|
|
}
|
|
}
|
|
|