static public function compare($version1, $version2, $operator = null)
    {
        $version1 = trim($version1);
        $version2 = trim($version2);
        
        // Because version_compare consider 2.1 < 2.1.0...
        $version1 = self::appendPatchVersion($version1);
        $version2 = self::appendPatchVersion($version2);
        
        // Check if the versions are known...
        $knownVersions = self::knownVersions();
        if (self::isKnown($version1) === false) {
            $msg = "Version '${version1}' is not a known QTI version. Known versions are '" . implode(', ', $knownVersions) . "'.";
            throw new InvalidArgumentException($msg);
        } elseif (self::isKnown($version2) === false) {
            $msg = "Version '${version2}' is not a known QTI version. Known versions are '" . implode(', ', $knownVersions) . "'.";
            throw new InvalidArgumentException($msg);
        }
        
        // Check if operator is correct.
        $knownOperators = array('<', 'lt', '<=', 'le', '>', 'gt', '>=', 'ge', '==', '=', 'eq', '!=', '<>', 'ne');
        if (is_null($operator) === true || in_array($operator, $knownOperators) === true) {
            return (is_null($operator) === true) ? version_compare($version1, $version2) : version_compare($version1, $version2, $operator);
        } else {
            $msg = "Unknown operator '${operator}'. Known operators are '" . implode(', ', $knownOperators) . "'.";
            throw new InvalidArgumentException($msg);
        }
    }