huesos/mirzaev/arming_bot/system/models/enumerations/currency.php

70 lines
1.3 KiB
PHP
Executable File

<?php
declare(strict_types=1);
namespace mirzaev\arming_bot\models\enumerations;
// Files of the project
use mirzaev\arming_bot\models\enumerations\language;
/**
* Types of currencies by ISO 4217 standart
*
* @package mirzaev\arming_bot\models\enumerations
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
enum currency
{
case usd;
case rub;
/**
* Label
*
* Initialize label of the currency
*
* @param language|null $language Language into which to translate
*
* @return string Translated label of the currency
*
* @todo
* 1. More currencies
* 2. Cases???
*/
public function label(?language $language = language::en): string
{
// Exit (success)
return match ($this) {
currency::usd => match ($language) {
language::en => 'Dollar',
language::ru => 'Доллар'
},
currency::rub => match ($language) {
language::en => 'Ruble',
language::ru => 'Рубль'
}
};
}
/**
* Symbol
*
* Initialize symbol of the currency
*
* @return string Symbol of the currency
*
* @todo
* 1. More currencies
*/
public function symbol(): string
{
// Exit (success)
return match ($this) {
currency::usd => '$',
currency::rub => '₽'
};
}
}