Version.php 781 B

123456789101112131415161718192021222324252627282930313233
  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. class Version
  10. {
  11. /**
  12. * Current Doctrine Version.
  13. */
  14. public const VERSION = '2.9.2';
  15. /**
  16. * Compares a Doctrine version with the current one.
  17. *
  18. * @param string $version The Doctrine version to compare to.
  19. *
  20. * @return int -1 if older, 0 if it is the same, 1 if version passed as argument is newer.
  21. */
  22. public static function compare($version)
  23. {
  24. $currentVersion = str_replace(' ', '', strtolower(self::VERSION));
  25. $version = str_replace(' ', '', $version);
  26. return version_compare($version, $currentVersion);
  27. }
  28. }