collection-crud/src/ValueObject/Money.php

24 lines
406 B
PHP
Raw Normal View History

<?php
namespace App\ValueObject;
use Stringable;
class Money implements Stringable {
private readonly float $value;
public function __construct($value)
{
2018-07-23 09:52:00 -04:00
$this->value = (float)str_replace(['$',','], '', $value);
}
2022-02-17 14:00:50 -05:00
public function getValue(): float
{
2018-07-23 09:52:00 -04:00
return (float)str_replace(['$',','], '', $this->value);
}
2022-02-17 14:00:50 -05:00
public function __toString(): string
{
return (string)$this->getValue();
}
}