collection-crud/src/ValueObject/Money.php

26 lines
485 B
PHP

<?php declare(strict_types=1);
namespace App\ValueObject;
use Stringable;
class Money implements Stringable
{
private readonly float $value;
public function __construct($value)
{
$this->value = (float) str_replace(['$', ','], '', $value);
}
public function getValue(): float
{
return (float) str_replace(['$', ','], '', $this->value);
}
public function __toString(): string
{
return (string) $this->getValue();
}
}