src/php/FlorianWolters/Component/Core/ComparableUtils.php
public static function compare(
        ComparableInterface $first = null,
        ComparableInterface $second = null,
        $nullGreater = false
    ) {
        if ($first === $second) {
            return self::EQUAL;
        } elseif (null === $first) {
            return $nullGreater
                ? self::FIRST_GT_SECOND
                : self::FIRST_LT_SECOND;
        } elseif (null === $second) {
            return $nullGreater
                ? self::FIRST_LT_SECOND
                : self::FIRST_GT_SECOND;
        }

        return $first->compareTo($second);
    }
public static function compare(
        ComparableInterface $first = null,
        ComparableInterface $second = null,
        $nullGreater = false
    ) {
        if ($first === $second) {
            return self::EQUAL;
        } elseif (null === $first) {
            return $nullGreater
                ? self::FIRST_GT_SECOND
                : self::FIRST_LT_SECOND;
        } elseif (null === $second) {
            return $nullGreater
                ? self::FIRST_LT_SECOND
                : self::FIRST_GT_SECOND;
        }

        return $first->compareTo($second);
    }
public static function compare ( ComparableInterface $ first = null , ComparableInterface $ second = null , $ nullGreater = false ) { if ( $ first === $ second ) { return self :: EQUAL ; } elseif ( null === $ first ) { return $ nullGreater ? self :: FIRST_GT_SECOND : self :: FIRST_LT_SECOND ; } elseif ( null === $ second ) { return $ nullGreater ? self :: FIRST_LT_SECOND : self :: FIRST_GT_SECOND ; } return $ first -> compareTo ( $ second ) ; }
Compares an object with another object for order.

Returns a negative integer, zero, or a positive integer as the first
object is less than, equal to, or greater than the second object.

The comparison of the objects is `null`-safe.

@param ComparableInterface|null $first       The first object to compare.
May be `null`.
@param ComparableInterface|null $second      The second object to
compare. May be `null`.
@param boolean                  $nullGreater If `true` `null` is
considered greater than a
non-`null` value or if
`false` `null` is considered
less than a non-`null`
value.

@return integer A negative integer, zero, or a positive integer as the
first object is less than, equal to, or greater than the
second object.
@throws ClassCastException If the arguments' types prevent them from
being compared.
@see ComparableInterface::compareTo
Compares an object with another object for order .