From: Greg Beaver Date: Wed, 27 Aug 2003 19:27:45 +0000 (+0000) Subject: adding betterStates() for usage in automatic dependency resolution X-Git-Tag: RELEASE_0_7~442 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3c87b23aa1498617c3765cec1467d378b1820ec6;p=php adding betterStates() for usage in automatic dependency resolution --- diff --git a/pear/PEAR/Common.php b/pear/PEAR/Common.php index 4f511a337c..8f75a86085 100644 --- a/pear/PEAR/Common.php +++ b/pear/PEAR/Common.php @@ -1357,6 +1357,30 @@ class PEAR_Common extends PEAR ); } + // }}} + // {{{ betterStates() + + /** + * Return an array containing all of the states that are more stable than + * or equal to the passed in state + * + * @param string Release state + * @param boolean Determines whether to include $state in the list + * @return false|array False if $state is not a valid release state + */ + function betterStates($state, $include = false) + { + static $states = array('devel', 'snapshot', 'alpha', 'beta', 'stable'); + $i = array_search($state, $states); + if ($i === false) { + return false; + } + if ($include) { + $i--; + } + return array_slice($states, $i + 1); + } + // }}} // {{{ detectDependencies()