collection-crud/src/ValueObject/Money.php

23 lines
359 B
PHP

<?php
namespace App\ValueObject;
class Money {
private 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();
}
}