]> granicus.if.org Git - php/commitdiff
adding betterStates() for usage in automatic dependency resolution
authorGreg Beaver <cellog@php.net>
Wed, 27 Aug 2003 19:27:45 +0000 (19:27 +0000)
committerGreg Beaver <cellog@php.net>
Wed, 27 Aug 2003 19:27:45 +0000 (19:27 +0000)
pear/PEAR/Common.php

index 4f511a337ca9e70a3e05c2107c985d7445181a21..8f75a86085a1a267041c283f52cc2fec660d7cc7 100644 (file)
@@ -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()