24 lines
406 B
PHP
24 lines
406 B
PHP
<?php
|
|
|
|
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();
|
|
}
|
|
}
|