2022-03-03 10:53:48 -05:00
|
|
|
<?php declare(strict_types=1);
|
2017-11-22 13:51:04 -05:00
|
|
|
|
2018-02-14 16:42:39 -05:00
|
|
|
namespace App\ValueObject;
|
2017-11-22 13:51:04 -05:00
|
|
|
|
2022-02-17 15:48:16 -05:00
|
|
|
use Stringable;
|
2017-11-22 13:51:04 -05:00
|
|
|
|
2022-03-03 10:53:48 -05:00
|
|
|
class Money implements Stringable
|
|
|
|
{
|
|
|
|
private readonly float $value;
|
2017-11-22 13:51:04 -05:00
|
|
|
|
2022-03-03 10:53:48 -05:00
|
|
|
public function __construct($value)
|
|
|
|
{
|
|
|
|
$this->value = (float) str_replace(['$', ','], '', $value);
|
|
|
|
}
|
2017-11-22 13:51:04 -05:00
|
|
|
|
2022-03-03 10:53:48 -05:00
|
|
|
public function getValue(): float
|
|
|
|
{
|
|
|
|
return (float) str_replace(['$', ','], '', $this->value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __toString(): string
|
|
|
|
{
|
|
|
|
return (string) $this->getValue();
|
|
|
|
}
|
2018-02-14 16:42:39 -05:00
|
|
|
}
|