CurrencyDataProvider.php
3 months ago
DateTimeFormatProvider.php
7 months ago
LanguageDataProvider.php
2 years ago
RegionDataProvider.php
1 year ago
CurrencyDataProvider.php
44 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Matomo - free/libre analytics platform |
| 5 | * |
| 6 | * @link https://matomo.org |
| 7 | * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 8 | */ |
| 9 | namespace Piwik\Intl\Data\Provider; |
| 10 | |
| 11 | use Piwik\Config\GeneralConfig; |
| 12 | /** |
| 13 | * Provides currency data. |
| 14 | */ |
| 15 | class CurrencyDataProvider |
| 16 | { |
| 17 | /** |
| 18 | * @var array<string, array{0: string, 1: string}>|null |
| 19 | */ |
| 20 | private $currencyList; |
| 21 | /** |
| 22 | * Returns the list of all known currency symbols. |
| 23 | * |
| 24 | * @return array An array mapping currency codes to their respective currency symbols |
| 25 | * and a description, eg, `array('USD' => array('$', 'US dollar'))`. |
| 26 | * @phpstan-return array<string, array{0: string, 1: string}> |
| 27 | * @api |
| 28 | */ |
| 29 | public function getCurrencyList() |
| 30 | { |
| 31 | if ($this->currencyList === null) { |
| 32 | $this->currencyList = (require __DIR__ . '/../Resources/currencies.php'); |
| 33 | /** @var array<string, string>|null $custom */ |
| 34 | $custom = GeneralConfig::getConfigValue('currencies'); |
| 35 | if (is_array($custom)) { |
| 36 | foreach ($custom as $code => $name) { |
| 37 | $this->currencyList[$code] = [$code, $name]; |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | return $this->currencyList; |
| 42 | } |
| 43 | } |
| 44 |