Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Class Currency {
- private $code;
- private $symbol;
- private $name;
- public function __construct(string $code) {
- //Add additional currencies and move this to a JSON file
- $currencies = [
- "USD" => [
- "symbol" => "$",
- "name" => "United States Dollar",
- ],
- "CAD" => [
- "symbol" => "$",
- "name" => "Canadian Dollar",
- ],
- ];
- /*
- * $currencies = json_decode(file_get_contents('...'));
- */
- $this->code = $code;
- $this->symbol = $currencies[$code]['symbol'];
- $this->name = $currencies[$code]['name'];
- }
- public function getCode(): String
- {
- return $this->code;
- }
- public function getSymbol(): String
- {
- return $this->symbol;
- }
- public function getName(): String
- {
- return $this->name;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement