public static function compareIdentifiers(array $left, array $right)
    {
        if ($left && empty($right)) {
            return self::LESS_THAN;
        } elseif (empty($left) && $right) {
            return self::GREATER_THAN;
        }

        $l = $left;
        $r = $right;
        $x = self::GREATER_THAN;
        $y = self::LESS_THAN;

        if (count($l) < count($r)) {
            $l = $right;
            $r = $left;
            $x = self::LESS_THAN;
            $y = self::GREATER_THAN;
        }

        foreach (array_keys($l) as $i) {
            if (!isset($r[$i])) {
                return $x;
            }

            if ($l[$i] === $r[$i]) {
                continue;
            }

            if (true === ($li = (false != preg_match('/^\d+$/', $l[$i])))) {
                $l[$i] = intval($l[$i]);
            }

            if (true === ($ri = (false != preg_match('/^\d+$/', $r[$i])))) {
                $r[$i] = intval($r[$i]);
            }

            if ($li && $ri) {
                return ($l[$i] > $r[$i]) ? $x : $y;
            } elseif (!$li && $ri) {
                return $x;
            } elseif ($li && !$ri) {
                return $y;
            }

            $result = strcmp($l[$i], $r[$i]);

            if ($result > 0) {
                return $x;
            } elseif ($result < 0) {
                return $y;
            }
        }

        return self::EQUAL_TO;
    }
public static function compareIdentifiers(array $left, array $right)
    {
        if ($left && empty($right)) {
            return self::LESS_THAN;
        } elseif (empty($left) && $right) {
            return self::GREATER_THAN;
        }

        $l = $left;
        $r = $right;
        $x = self::GREATER_THAN;
        $y = self::LESS_THAN;

        if (count($l) < count($r)) {
            $l = $right;
            $r = $left;
            $x = self::LESS_THAN;
            $y = self::GREATER_THAN;
        }

        foreach (array_keys($l) as $i) {
            if (!isset($r[$i])) {
                return $x;
            }

            if ($l[$i] === $r[$i]) {
                continue;
            }

            if (true === ($li = (false != preg_match('/^\d+$/', $l[$i])))) {
                $l[$i] = intval($l[$i]);
            }

            if (true === ($ri = (false != preg_match('/^\d+$/', $r[$i])))) {
                $r[$i] = intval($r[$i]);
            }

            if ($li && $ri) {
                return ($l[$i] > $r[$i]) ? $x : $y;
            } elseif (!$li && $ri) {
                return $x;
            } elseif ($li && !$ri) {
                return $y;
            }

            $result = strcmp($l[$i], $r[$i]);

            if ($result > 0) {
                return $x;
            } elseif ($result < 0) {
                return $y;
            }
        }

        return self::EQUAL_TO;
    }
public static function compareIdentifiers ( array $ left , array $ right ) { if ( $ left && empty ( $ right ) ) { return self :: LESS_THAN ; } elseif ( empty ( $ left ) && $ right ) { return self :: GREATER_THAN ; } $ l = $ left ; $ r = $ right ; $ x = self :: GREATER_THAN ; $ y = self :: LESS_THAN ; if ( count ( $ l ) < count ( $ r ) ) { $ l = $ right ; $ r = $ left ; $ x = self :: LESS_THAN ; $ y = self :: GREATER_THAN ; } foreach ( array_keys ( $ l ) as $ i ) { if ( ! isset ( $ r [ $ i ] ) ) { return $ x ; } if ( $ l [ $ i ] === $ r [ $ i ] ) { continue ; } if ( true === ( $ li = ( false != preg_match ( '/^\d+$/' , $ l [ $ i ] ) ) ) ) { $ l [ $ i ] = intval ( $ l [ $ i ] ) ; } if ( true === ( $ ri = ( false != preg_match ( '/^\d+$/' , $ r [ $ i ] ) ) ) ) { $ r [ $ i ] = intval ( $ r [ $ i ] ) ; } if ( $ li && $ ri ) { return ( $ l [ $ i ] > $ r [ $ i ] ) ? $ x : $ y ; } elseif ( ! $ li && $ ri ) { return $ x ; } elseif ( $ li && ! $ ri ) { return $ y ; } $ result = strcmp ( $ l [ $ i ] , $ r [ $ i ] ) ; if ( $ result > 0 ) { return $ x ; } elseif ( $ result < 0 ) { return $ y ; } } return self :: EQUAL_TO ; }
Compares the identifier components of the left and right versions.

@param array $left  The left identifiers.
@param array $right The right identifiers.

@return integer Returns Comparator::EQUAL_TO if the two identifiers are
equal. If the left identifiers is less than the right
identifiers, Comparator::LESS_THAN is returned. If the
left identifiers is greater than the right identifiers,
Comparator::GREATER_THAN is returned.
Compares the identifier components of the left and right versions .