Binary.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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_Measure
  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. * Implement needed classes
  23. */
  24. #require_once 'Zend/Measure/Abstract.php';
  25. #require_once 'Zend/Locale.php';
  26. /**
  27. * Class for handling binary conversions
  28. *
  29. * @category Zend
  30. * @package Zend_Measure
  31. * @subpackage Zend_Measure_Binary
  32. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. class Zend_Measure_Binary extends Zend_Measure_Abstract
  36. {
  37. const STANDARD = 'BYTE';
  38. const BIT = 'BIT';
  39. const CRUMB = 'CRUMB';
  40. const NIBBLE = 'NIBBLE';
  41. const BYTE = 'BYTE';
  42. const KILOBYTE = 'KILOBYTE';
  43. const KIBIBYTE = 'KIBIBYTE';
  44. const KILO_BINARY_BYTE = 'KILO_BINARY_BYTE';
  45. const KILOBYTE_SI = 'KILOBYTE_SI';
  46. const MEGABYTE = 'MEGABYTE';
  47. const MEBIBYTE = 'MEBIBYTE';
  48. const MEGA_BINARY_BYTE = 'MEGA_BINARY_BYTE';
  49. const MEGABYTE_SI = 'MEGABYTE_SI';
  50. const GIGABYTE = 'GIGABYTE';
  51. const GIBIBYTE = 'GIBIBYTE';
  52. const GIGA_BINARY_BYTE = 'GIGA_BINARY_BYTE';
  53. const GIGABYTE_SI = 'GIGABYTE_SI';
  54. const TERABYTE = 'TERABYTE';
  55. const TEBIBYTE = 'TEBIBYTE';
  56. const TERA_BINARY_BYTE = 'TERA_BINARY_BYTE';
  57. const TERABYTE_SI = 'TERABYTE_SI';
  58. const PETABYTE = 'PETABYTE';
  59. const PEBIBYTE = 'PEBIBYTE';
  60. const PETA_BINARY_BYTE = 'PETA_BINARY_BYTE';
  61. const PETABYTE_SI = 'PETABYTE_SI';
  62. const EXABYTE = 'EXABYTE';
  63. const EXBIBYTE = 'EXBIBYTE';
  64. const EXA_BINARY_BYTE = 'EXA_BINARY_BYTE';
  65. const EXABYTE_SI = 'EXABYTE_SI';
  66. const ZETTABYTE = 'ZETTABYTE';
  67. const ZEBIBYTE = 'ZEBIBYTE';
  68. const ZETTA_BINARY_BYTE = 'ZETTA_BINARY_BYTE';
  69. const ZETTABYTE_SI = 'ZETTABYTE_SI';
  70. const YOTTABYTE = 'YOTTABYTE';
  71. const YOBIBYTE = 'YOBIBYTE';
  72. const YOTTA_BINARY_BYTE = 'YOTTA_BINARY_BYTE';
  73. const YOTTABYTE_SI = 'YOTTABYTE_SI';
  74. /**
  75. * Calculations for all binary units
  76. *
  77. * @var array
  78. */
  79. protected $_units = array(
  80. 'BIT' => array('0.125', 'b'),
  81. 'CRUMB' => array('0.25', 'crumb'),
  82. 'NIBBLE' => array('0.5', 'nibble'),
  83. 'BYTE' => array('1', 'B'),
  84. 'KILOBYTE' => array('1024', 'kB'),
  85. 'KIBIBYTE' => array('1024', 'KiB'),
  86. 'KILO_BINARY_BYTE' => array('1024', 'KiB'),
  87. 'KILOBYTE_SI' => array('1000', 'kB.'),
  88. 'MEGABYTE' => array('1048576', 'MB'),
  89. 'MEBIBYTE' => array('1048576', 'MiB'),
  90. 'MEGA_BINARY_BYTE' => array('1048576', 'MiB'),
  91. 'MEGABYTE_SI' => array('1000000', 'MB.'),
  92. 'GIGABYTE' => array('1073741824', 'GB'),
  93. 'GIBIBYTE' => array('1073741824', 'GiB'),
  94. 'GIGA_BINARY_BYTE' => array('1073741824', 'GiB'),
  95. 'GIGABYTE_SI' => array('1000000000', 'GB.'),
  96. 'TERABYTE' => array('1099511627776', 'TB'),
  97. 'TEBIBYTE' => array('1099511627776', 'TiB'),
  98. 'TERA_BINARY_BYTE' => array('1099511627776', 'TiB'),
  99. 'TERABYTE_SI' => array('1000000000000', 'TB.'),
  100. 'PETABYTE' => array('1125899906842624', 'PB'),
  101. 'PEBIBYTE' => array('1125899906842624', 'PiB'),
  102. 'PETA_BINARY_BYTE' => array('1125899906842624', 'PiB'),
  103. 'PETABYTE_SI' => array('1000000000000000', 'PB.'),
  104. 'EXABYTE' => array('1152921504606846976', 'EB'),
  105. 'EXBIBYTE' => array('1152921504606846976', 'EiB'),
  106. 'EXA_BINARY_BYTE' => array('1152921504606846976', 'EiB'),
  107. 'EXABYTE_SI' => array('1000000000000000000', 'EB.'),
  108. 'ZETTABYTE' => array('1180591620717411303424', 'ZB'),
  109. 'ZEBIBYTE' => array('1180591620717411303424', 'ZiB'),
  110. 'ZETTA_BINARY_BYTE'=> array('1180591620717411303424', 'ZiB'),
  111. 'ZETTABYTE_SI' => array('1000000000000000000000', 'ZB.'),
  112. 'YOTTABYTE' => array('1208925819614629174706176', 'YB'),
  113. 'YOBIBYTE' => array('1208925819614629174706176', 'YiB'),
  114. 'YOTTA_BINARY_BYTE'=> array('1208925819614629174706176', 'YiB'),
  115. 'YOTTABYTE_SI' => array('1000000000000000000000000', 'YB.'),
  116. 'STANDARD' => 'BYTE'
  117. );
  118. }