I'm not sure how name this but I have already seen in C# something like:
decimal value = 12.01;
print obj->getAmount() // 1002.01
print obj->getAmount()->format('...'); // 1.002,01
So, On PHP I tried something like:
class Account {
public function getAmount() {
return new Decimal($this->_amount);
}
}
class Decimal {
private $_value;
public function __construct($value) {
$this->_value = $value;
return (float) $this->_value;
}
public function format() {
return number_format($this->_value, 2, ',', '.');
}
}
Where was possible get the value in two ways:
$account->getAmount() // 1002.01
$account->getAmount()->format() // 1.002,01
But, if this is possible I would say that something is missing and I'm not sure how to do.