Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. Class Currency {
  2.  
  3.     private $code;
  4.     private $symbol;
  5.     private $name;
  6.  
  7.     public function __construct(string $code) {
  8.         //Add additional currencies and move this to a JSON file
  9.         $currencies = [
  10.             "USD" => [
  11.                 "symbol" => "$",
  12.                 "name" => "United States Dollar",
  13.             ],
  14.             "CAD" => [
  15.                 "symbol" => "$",
  16.                 "name" => "Canadian Dollar",
  17.             ],
  18.         ];
  19.         /*
  20.          * $currencies = json_decode(file_get_contents('...'));
  21.          */
  22.  
  23.         $this->code = $code;
  24.         $this->symbol = $currencies[$code]['symbol'];
  25.         $this->name = $currencies[$code]['name'];  
  26.     }
  27.  
  28.     public function getCode(): String
  29.     {
  30.         return $this->code;
  31.     }
  32.    
  33.     public function getSymbol(): String
  34.     {
  35.         return $this->symbol;
  36.     }
  37.    
  38.     public function getName(): String
  39.     {
  40.         return $this->name;
  41.     }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement