Version.php 868 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Doctrine\DBAL;
  3. use function str_replace;
  4. use function strtolower;
  5. use function version_compare;
  6. /**
  7. * Class to store and retrieve the version of Doctrine.
  8. *
  9. * @internal
  10. * @deprecated Refrain from checking the DBAL version at runtime.
  11. */
  12. class Version
  13. {
  14. /**
  15. * Current Doctrine Version.
  16. */
  17. public const VERSION = '2.12.2-DEV';
  18. /**
  19. * Compares a Doctrine version with the current one.
  20. *
  21. * @param string $version The Doctrine version to compare to.
  22. *
  23. * @return int -1 if older, 0 if it is the same, 1 if version passed as argument is newer.
  24. */
  25. public static function compare($version)
  26. {
  27. $currentVersion = str_replace(' ', '', strtolower(self::VERSION));
  28. $version = str_replace(' ', '', $version);
  29. return version_compare($version, $currentVersion);
  30. }
  31. }