1 | <?php |
||
7 | trait CurrencyTraits |
||
8 | { |
||
9 | // Supported currencies: |
||
10 | private $_currencies = [ |
||
11 | 'USD', 'GBP', 'EUR', 'JPY', 'XAF', 'CNY', 'QAR', 'ZAR', 'SEK', |
||
12 | ]; |
||
13 | |||
14 | // The base currency (default is USD): |
||
15 | private $baseCurrency; |
||
16 | |||
17 | // Regular Expression for the currency: |
||
18 | private $currencyRegExp = '/^[A-Z]{3}$/'; |
||
19 | |||
20 | // Sanitize a currency code: |
||
21 | private function sanitizeCurrencyCode(string $code) |
||
27 | |||
28 | // Set the base currency: |
||
29 | public function setBaseCurrency(string $currency) |
||
42 | |||
43 | // Runs tests to verify a currency code: |
||
44 | private function verifyCurrencyCode(string $code) |
||
58 | |||
59 | // Validate a currency code is in the correct format: |
||
60 | private function validateCurrencyCodeFormat(string $code = null) |
||
78 | |||
79 | // Check if a currency code is in the supported range: |
||
80 | public function currencyIsSupported(string $code) |
||
90 | |||
91 | public function getBaseCurrency() |
||
95 | |||
96 | // Get the supported currencies: |
||
97 | public function getSupportedCurrencies(string $concat = null) |
||
101 | } |
||
102 |