This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class Money | |
{ | |
private string $amount; | |
private string $currency; | |
public function __construct(private string $amount, private string $currency) | |
{ | |
if (!is_numeric($amount)) { | |
throw new InvalidAmountException::notNumeric($amount); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class Money | |
{ | |
public function __construct(private string $amount, private Currency $currency) | |
{} | |
public function amount(): string | |
{ | |
return $this->amount; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
readonly class Money | |
{ | |
private function __construct(private string $amount, private Currency $currency) | |
{} | |
public static function eur(string $amount): self | |
{ | |
return new static($amount, Currency::eur()); | |
} |
OlderNewer