You are here

function composer_manager_compare_stability in Composer Manager 6

Same name and namespace in other branches
  1. 6.2 composer_manager.writer.inc \composer_manager_compare_stability()
  2. 7.2 composer_manager.writer.inc \composer_manager_compare_stability()
  3. 7 composer_manager.writer.inc \composer_manager_compare_stability()

Compares the passed minimum stability requirements.

Return value

int Returns -1 if the first version is lower than the second, 0 if they are equal, and 1 if the second is lower.

Throws

\UnexpectedValueException

1 call to composer_manager_compare_stability()
composer_manager_build_json in ./composer_manager.writer.inc
Builds the JSON array ccontaining the combined requirements of each module's composer.json file.

File

./composer_manager.writer.inc, line 224
Functions related to the creation of the consolidated composer.json file.

Code

function composer_manager_compare_stability($a, $b) {
  $number = array(
    'dev' => 0,
    'alpha' => 1,
    'beta' => 2,
    'RC' => 3,
    'rc' => 3,
    'stable' => 4,
  );
  if (!isset($number[$a]) || !isset($number[$b])) {
    throw new \UnexpectedValueException(t('Unexpected value for "minimum-stability"'));
  }
  if ($number[$a] == $number[$b]) {
    return 0;
  }
  else {
    return $number[$a] < $number[$b] ? -1 : 1;
  }
}