private static function Project::compareVersions

8.0.x Project.php private static Project::compareVersions(array $a, array $b)
7.x Project.php private static Project::compareVersions(array $a, array $b)
master Project.php private static Project::compareVersions(array $a, array $b)

Comparison routine to order releases by version.

Parameters

array $a: Release to compare.

array $b: Release to compare.

Return value

int -1, 0 or 1 whether $a is greater, equal or lower than $b.

1 call to Project::compareVersions()
Project::filterReleases in lib/Drush/UpdateService/Project.php
Filter project releases by a criteria and returns a list.

File

lib/Drush/UpdateService/Project.php, line 447

Namespace

Drush\UpdateService

Class

Project
Representation of a project's release info from the update service.

Code

private static function compareVersions(array $a, array $b) {
  $defaults = array(
    'version_patch' => '',
    'version_extra' => '',
    'date' => 0,
  );
  $a += $defaults;
  $b += $defaults;
  if ($a['version_major'] != $b['version_major']) {
    return ($a['version_major'] > $b['version_major']) ? -1 : 1;
  }
  else if ($a['version_patch'] != $b['version_patch']) {
    return ($a['version_patch'] > $b['version_patch']) ? -1 : 1;
  }
  else if ($a['version_extra'] != $b['version_extra']) {
    // Don't rely on version_extra alphabetical order.
    return ($a['date'] > $b['date']) ? -1 : 1;
  }

  return 0;
}