Doctrine\Common\Version::compare PHP Method

compare() public static method

Compares a Doctrine version with the current one.
public static compare ( string $version ) : integer
$version string Doctrine version to compare.
return integer Returns -1 if older, 0 if it is the same, 1 if version passed as argument is newer.
    public static function compare($version)
    {
        $currentVersion = str_replace(' ', '', strtolower(self::VERSION));
        $version = str_replace(' ', '', $version);

        return version_compare($version, $currentVersion);
    }

Usage Example

 /**
  * Get real class name of a reference that could be a proxy
  *
  * @param string $className Class name of reference object
  *
  * @return string
  */
 protected function getRealClass($className)
 {
     if (Version::compare('2.2.0') <= 0) {
         return ClassUtils::getRealClass($className);
     }
     if (substr($className, -5) === 'Proxy') {
         return substr($className, 0, -5);
     }
     return $className;
 }
All Usage Examples Of Doctrine\Common\Version::compare
Version