File indexing completed on 2024-04-28 06:00:03

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Version
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0019  * @version    $Id$
0020  */
0021 
0022 /**
0023  * Class to store and retrieve the version of Zend Framework.
0024  *
0025  * @category   Zend
0026  * @package    Zend_Version
0027  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0028  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0029  */
0030 final class Zend_Version
0031 {
0032     /**
0033      * Zend Framework version identification - see compareVersion()
0034      */
0035     const VERSION = '1.12.20';
0036 
0037     /**
0038      * The latest stable version Zend Framework available
0039      *
0040      * @var string
0041      */
0042     protected static $_latestVersion;
0043 
0044     /**
0045      * Compare the specified Zend Framework version string $version
0046      * with the current Zend_Version::VERSION of Zend Framework.
0047      *
0048      * @param  string  $version  A version string (e.g. "0.7.1").
0049      * @return int           -1 if the $version is older,
0050      *                           0 if they are the same,
0051      *                           and +1 if $version is newer.
0052      *
0053      */
0054     public static function compareVersion($version)
0055     {
0056         $version = strtolower($version);
0057         $version = preg_replace('/(\d)pr(\d?)/', '$1a$2', $version);
0058         return version_compare($version, strtolower(self::VERSION));
0059     }
0060 
0061     /**
0062      * Fetches the version of the latest stable release
0063      *
0064      * @link http://framework.zend.com/download/latest
0065      * @return string
0066      */
0067     public static function getLatest()
0068     {
0069         if (null === self::$_latestVersion) {
0070             self::$_latestVersion = 'not available';
0071 
0072             $handle = fopen('http://framework.zend.com/api/zf-version', 'r');
0073             if (false !== $handle) {
0074                 self::$_latestVersion = stream_get_contents($handle);
0075                 fclose($handle);
0076             }
0077         }
0078 
0079         return self::$_latestVersion;
0080     }
0081 }