Skip to content

Instantly share code, notes, and snippets.

@dhrrgn
Created June 17, 2014 19:52
Show Gist options
  • Save dhrrgn/4d74ab958c4031fa9a14 to your computer and use it in GitHub Desktop.
Save dhrrgn/4d74ab958c4031fa9a14 to your computer and use it in GitHub Desktop.
<?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