Created
June 17, 2014 19:52
-
-
Save dhrrgn/4d74ab958c4031fa9a14 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Currency { | |
private $value = 0; | |
public function setValue($value) | |
{ | |
$this->value = $value; | |
} | |
public function getValue() | |
{ | |
return $this->value; | |
} | |
} | |
// This is the decorator. | |
class USCurrency { | |
private $currency; | |
public function __construct(Currency $currency) | |
{ | |
$this->currency = $currency; | |
} | |
public function formatValue() | |
{ | |
setlocale(LC_MONETARY, 'en_US'); | |
return money_format('%n', $this->currency->getValue()); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment