You are here

class Comparator in Zircon Profile 8

Same name in this branch
  1. 8 vendor/sebastian/comparator/src/Comparator.php \SebastianBergmann\Comparator\Comparator
  2. 8 vendor/composer/semver/src/Comparator.php \Composer\Semver\Comparator
Same name and namespace in other branches
  1. 8.0 vendor/composer/semver/src/Comparator.php \Composer\Semver\Comparator

Hierarchy

Expanded class hierarchy of Comparator

File

vendor/composer/semver/src/Comparator.php, line 16

Namespace

Composer\Semver
View source
class Comparator {

  /**
   * Evaluates the expression: $version1 > $version2.
   *
   * @param string $version1
   * @param string $version2
   *
   * @return bool
   */
  public static function greaterThan($version1, $version2) {
    return self::compare($version1, '>', $version2);
  }

  /**
   * Evaluates the expression: $version1 >= $version2.
   *
   * @param string $version1
   * @param string $version2
   *
   * @return bool
   */
  public static function greaterThanOrEqualTo($version1, $version2) {
    return self::compare($version1, '>=', $version2);
  }

  /**
   * Evaluates the expression: $version1 < $version2.
   *
   * @param string $version1
   * @param string $version2
   *
   * @return bool
   */
  public static function lessThan($version1, $version2) {
    return self::compare($version1, '<', $version2);
  }

  /**
   * Evaluates the expression: $version1 <= $version2.
   *
   * @param string $version1
   * @param string $version2
   *
   * @return bool
   */
  public static function lessThanOrEqualTo($version1, $version2) {
    return self::compare($version1, '<=', $version2);
  }

  /**
   * Evaluates the expression: $version1 == $version2.
   *
   * @param string $version1
   * @param string $version2
   *
   * @return bool
   */
  public static function equalTo($version1, $version2) {
    return self::compare($version1, '==', $version2);
  }

  /**
   * Evaluates the expression: $version1 != $version2.
   *
   * @param string $version1
   * @param string $version2
   *
   * @return bool
   */
  public static function notEqualTo($version1, $version2) {
    return self::compare($version1, '!=', $version2);
  }

  /**
   * Evaluates the expression: $version1 $operator $version2.
   *
   * @param string $version1
   * @param string $operator
   * @param string $version2
   *
   * @return bool
   */
  public static function compare($version1, $operator, $version2) {
    $constraint = new Constraint($operator, $version2);
    return $constraint
      ->matches(new Constraint('==', $version1));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Comparator::compare public static function Evaluates the expression: $version1 $operator $version2.
Comparator::equalTo public static function Evaluates the expression: $version1 == $version2.
Comparator::greaterThan public static function Evaluates the expression: $version1 > $version2.
Comparator::greaterThanOrEqualTo public static function Evaluates the expression: $version1 >= $version2.
Comparator::lessThan public static function Evaluates the expression: $version1 < $version2.
Comparator::lessThanOrEqualTo public static function Evaluates the expression: $version1 <= $version2.
Comparator::notEqualTo public static function Evaluates the expression: $version1 != $version2.