CurrencyInterface.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework;
  7. /**
  8. * @api
  9. * @since 100.0.2
  10. */
  11. interface CurrencyInterface
  12. {
  13. /**
  14. * Returns a localized currency string
  15. *
  16. * @param integer|float $value OPTIONAL Currency value
  17. * @param array $options OPTIONAL options to set temporary
  18. * @throws \Zend_Currency_Exception When the value is not a number
  19. * @return string
  20. */
  21. public function toCurrency($value = null, array $options = []);
  22. /**
  23. * Sets the formating options of the localized currency string
  24. * If no parameter is passed, the standard setting of the
  25. * actual set locale will be used
  26. *
  27. * @param array $options (Optional) Options to set
  28. * @return \Magento\Framework\CurrencyInterface
  29. */
  30. public function setFormat(array $options = []);
  31. /**
  32. * Returns the actual or details of other currency symbols,
  33. * when no symbol is available it returns the currency shortname (f.e. FIM for Finnian Mark)
  34. *
  35. * @param string $currency (Optional) Currency name
  36. * @param string $locale (Optional) Locale to display informations
  37. * @return string
  38. */
  39. public function getSymbol($currency = null, $locale = null);
  40. /**
  41. * Returns the actual or details of other currency shortnames
  42. *
  43. * @param string $currency OPTIONAL Currency's name
  44. * @param string $locale OPTIONAL The locale
  45. * @return string
  46. */
  47. public function getShortName($currency = null, $locale = null);
  48. /**
  49. * Returns the actual or details of other currency names
  50. *
  51. * @param string $currency (Optional) Currency's short name
  52. * @param string $locale (Optional) The locale
  53. * @return string
  54. */
  55. public function getName($currency = null, $locale = null);
  56. /**
  57. * Returns a list of regions where this currency is or was known
  58. *
  59. * @param string $currency OPTIONAL Currency's short name
  60. * @throws \Zend_Currency_Exception When no currency was defined
  61. * @return array List of regions
  62. */
  63. public function getRegionList($currency = null);
  64. /**
  65. * Returns a list of currencies which are used in this region
  66. * a region name should be 2 charachters only (f.e. EG, DE, US)
  67. * If no region is given, the actual region is used
  68. *
  69. * @param string $region OPTIONAL Region to return the currencies for
  70. * @return array List of currencies
  71. */
  72. public function getCurrencyList($region = null);
  73. /**
  74. * Returns the actual currency name
  75. *
  76. * @return string
  77. */
  78. public function toString();
  79. /**
  80. * Returns the set cache
  81. *
  82. * @return \Zend_Cache_Core The set cache
  83. */
  84. public static function getCache();
  85. /**
  86. * Sets a cache for \Magento\Framework\Currency
  87. *
  88. * @param \Zend_Cache_Core $cache Cache to set
  89. * @return void
  90. */
  91. public static function setCache(\Zend_Cache_Core $cache);
  92. /**
  93. * Returns true when a cache is set
  94. *
  95. * @return boolean
  96. */
  97. public static function hasCache();
  98. /**
  99. * Removes any set cache
  100. *
  101. * @return void
  102. */
  103. public static function removeCache();
  104. /**
  105. * Clears all set cache data
  106. *
  107. * @param string $tag Tag to clear when the default tag name is not used
  108. * @return void
  109. */
  110. public static function clearCache($tag = null);
  111. /**
  112. * Sets a new locale for data retrievement
  113. * Example: 'de_XX' will be set to 'de' because 'de_XX' does not exist
  114. * 'xx_YY' will be set to 'root' because 'xx' does not exist
  115. *
  116. * @param string $locale (Optional) Locale for parsing input
  117. * @throws \Zend_Currency_Exception When the given locale does not exist
  118. * @return $this
  119. */
  120. public function setLocale($locale = null);
  121. /**
  122. * Returns the actual set locale
  123. *
  124. * @return string
  125. */
  126. public function getLocale();
  127. /**
  128. * Returns the value
  129. *
  130. * @return float
  131. */
  132. public function getValue();
  133. /**
  134. * Adds a currency
  135. *
  136. * @param float|integer|\Magento\Framework\CurrencyInterface $value Add this value to currency
  137. * @param string|\Magento\Framework\CurrencyInterface $currency The currency to add
  138. * @return \Magento\Framework\CurrencyInterface
  139. */
  140. public function setValue($value, $currency = null);
  141. /**
  142. * Adds a currency
  143. *
  144. * @param float|integer|\Magento\Framework\CurrencyInterface $value Add this value to currency
  145. * @param string|\Magento\Framework\CurrencyInterface $currency The currency to add
  146. * @return \Magento\Framework\CurrencyInterface
  147. */
  148. public function add($value, $currency = null);
  149. /**
  150. * Substracts a currency
  151. *
  152. * @param float|integer|\Magento\Framework\CurrencyInterface $value Substracts this value from currency
  153. * @param string|\Magento\Framework\CurrencyInterface $currency The currency to substract
  154. * @return \Magento\Framework\CurrencyInterface
  155. */
  156. public function sub($value, $currency = null);
  157. /**
  158. * Divides a currency
  159. *
  160. * @param float|integer|\Magento\Framework\CurrencyInterface $value Divides this value from currency
  161. * @param string|\Magento\Framework\CurrencyInterface $currency The currency to divide
  162. * @return \Magento\Framework\CurrencyInterface
  163. */
  164. public function div($value, $currency = null);
  165. /**
  166. * Multiplies a currency
  167. *
  168. * @param float|integer|\Magento\Framework\CurrencyInterface $value Multiplies this value from currency
  169. * @param string|\Magento\Framework\CurrencyInterface $currency The currency to multiply
  170. * @return \Magento\Framework\CurrencyInterface
  171. */
  172. public function mul($value, $currency = null);
  173. /**
  174. * Calculates the modulo from a currency
  175. *
  176. * @param float|integer|\Magento\Framework\CurrencyInterface $value Calculate modulo from this value
  177. * @param string|\Magento\Framework\CurrencyInterface $currency The currency to calculate the modulo
  178. * @return \Magento\Framework\CurrencyInterface
  179. */
  180. public function mod($value, $currency = null);
  181. /**
  182. * Compares two currencies
  183. *
  184. * @param float|integer|\Magento\Framework\CurrencyInterface $value Compares the currency with this value
  185. * @param string|\Magento\Framework\CurrencyInterface $currency The currency to compare this value from
  186. * @return \Magento\Framework\CurrencyInterface
  187. */
  188. public function compare($value, $currency = null);
  189. /**
  190. * Returns true when the two currencies are equal
  191. *
  192. * @param float|integer|\Magento\Framework\CurrencyInterface $value Compares the currency with this value
  193. * @param string|\Magento\Framework\CurrencyInterface $currency The currency to compare this value from
  194. * @return boolean
  195. */
  196. public function equals($value, $currency = null);
  197. /**
  198. * Returns true when the currency is more than the given value
  199. *
  200. * @param float|integer|\Magento\Framework\CurrencyInterface $value Compares the currency with this value
  201. * @param string|\Magento\Framework\CurrencyInterface $currency The currency to compare this value from
  202. * @return boolean
  203. */
  204. public function isMore($value, $currency = null);
  205. /**
  206. * Returns true when the currency is less than the given value
  207. *
  208. * @param float|integer|\Magento\Framework\CurrencyInterface $value Compares the currency with this value
  209. * @param string|\Magento\Framework\CurrencyInterface $currency The currency to compare this value from
  210. * @return boolean
  211. */
  212. public function isLess($value, $currency = null);
  213. }