Version.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Version
  17. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id$
  20. */
  21. /**
  22. * Class to store and retrieve the version of Zend Framework.
  23. *
  24. * @category Zend
  25. * @package Zend_Version
  26. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  27. * @license http://framework.zend.com/license/new-bsd New BSD License
  28. */
  29. final class Zend_Version
  30. {
  31. /**
  32. * Zend Framework version identification - see compareVersion()
  33. */
  34. const VERSION = '1.12.20dev';
  35. /**
  36. * The latest stable version Zend Framework available
  37. *
  38. * @var string
  39. */
  40. protected static $_latestVersion;
  41. /**
  42. * Compare the specified Zend Framework version string $version
  43. * with the current Zend_Version::VERSION of Zend Framework.
  44. *
  45. * @param string $version A version string (e.g. "0.7.1").
  46. * @return int -1 if the $version is older,
  47. * 0 if they are the same,
  48. * and +1 if $version is newer.
  49. *
  50. */
  51. public static function compareVersion($version)
  52. {
  53. $version = strtolower($version);
  54. $version = preg_replace('/(\d)pr(\d?)/', '$1a$2', $version);
  55. return version_compare($version, strtolower(self::VERSION));
  56. }
  57. /**
  58. * Fetches the version of the latest stable release
  59. *
  60. * @link http://framework.zend.com/download/latest
  61. * @return string
  62. */
  63. public static function getLatest()
  64. {
  65. if (null === self::$_latestVersion) {
  66. self::$_latestVersion = 'not available';
  67. $handle = fopen('http://framework.zend.com/api/zf-version', 'r');
  68. if (false !== $handle) {
  69. self::$_latestVersion = stream_get_contents($handle);
  70. fclose($handle);
  71. }
  72. }
  73. return self::$_latestVersion;
  74. }
  75. }