Version.php 785 Bytes
Newer Older
1
<?php
2

3 4
namespace Doctrine\DBAL;

5 6 7 8
use function str_replace;
use function strtolower;
use function version_compare;

9
/**
Benjamin Morel's avatar
Benjamin Morel committed
10
 * Class to store and retrieve the version of Doctrine.
11 12 13 14
 */
class Version
{
    /**
Benjamin Morel's avatar
Benjamin Morel committed
15
     * Current Doctrine Version.
16
     */
17
    public const VERSION = '2.9.1-DEV';
18 19 20 21

    /**
     * Compares a Doctrine version with the current one.
     *
Benjamin Morel's avatar
Benjamin Morel committed
22 23
     * @param string $version The Doctrine version to compare to.
     *
24
     * @return int -1 if older, 0 if it is the same, 1 if version passed as argument is newer.
25 26 27 28
     */
    public static function compare($version)
    {
        $currentVersion = str_replace(' ', '', strtolower(self::VERSION));
29
        $version        = str_replace(' ', '', $version);
30 31 32

        return version_compare($version, $currentVersion);
    }
33
}