| 1: | <?php |
| 2: | |
| 3: | namespace IPay\ValueObjects; |
| 4: | |
| 5: | use EventSauce\ObjectHydrator\Constructor; |
| 6: | use EventSauce\ObjectHydrator\PropertyCasters\CastToDateTimeImmutable; |
| 7: | use EventSauce\ObjectHydrator\PropertyCasters\CastToType; |
| 8: | |
| 9: | readonly class Transaction |
| 10: | { |
| 11: | private function __construct( |
| 12: | public string $currency, |
| 13: | public int $amount, |
| 14: | public string $remark, |
| 15: | public string $corresponsiveAccount, |
| 16: | public string $corresponsiveName, |
| 17: | public \DateTimeImmutable $processDate, |
| 18: | ) { |
| 19: | } |
| 20: | |
| 21: | #[Constructor] |
| 22: | public static function create( |
| 23: | string $currency, |
| 24: | #[CastToType('integer')] |
| 25: | int $amount, |
| 26: | string $remark, |
| 27: | string $corresponsiveAccount, |
| 28: | string $corresponsiveName, |
| 29: | #[CastToDateTimeImmutable('d-m-Y H:i:s')] |
| 30: | \DateTimeImmutable $processDate, |
| 31: | ): self { |
| 32: | return new self( |
| 33: | $currency, |
| 34: | $amount, |
| 35: | $remark, |
| 36: | $corresponsiveAccount, |
| 37: | $corresponsiveName, |
| 38: | $processDate, |
| 39: | ); |
| 40: | } |
| 41: | } |
| 42: | |