Skip to content

Commit a04c760

Browse files
authored
Merge pull request #838 from bavix/11.x-dto-refactoring
11.x dto refactoring
2 parents f956ed0 + 9579ffd commit a04c760

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/Internal/Assembler/TransactionDtoAssembler.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66

77
use Bavix\Wallet\Internal\Dto\TransactionDto;
88
use Bavix\Wallet\Internal\Dto\TransactionDtoInterface;
9+
use Bavix\Wallet\Internal\Service\ClockServiceInterface;
910
use Bavix\Wallet\Internal\Service\UuidFactoryServiceInterface;
1011
use Illuminate\Database\Eloquent\Model;
1112

1213
final readonly class TransactionDtoAssembler implements TransactionDtoAssemblerInterface
1314
{
1415
public function __construct(
15-
private UuidFactoryServiceInterface $uuidService
16+
private UuidFactoryServiceInterface $uuidService,
17+
private ClockServiceInterface $clockService,
1618
) {
1719
}
1820

@@ -33,7 +35,9 @@ public function create(
3335
$type,
3436
$amount,
3537
$confirmed,
36-
$meta
38+
$meta,
39+
$this->clockService->now(),
40+
$this->clockService->now(),
3741
);
3842
}
3943
}

src/Internal/Assembler/TransferDtoAssembler.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66

77
use Bavix\Wallet\Internal\Dto\TransferDto;
88
use Bavix\Wallet\Internal\Dto\TransferDtoInterface;
9+
use Bavix\Wallet\Internal\Service\ClockServiceInterface;
910
use Bavix\Wallet\Internal\Service\UuidFactoryServiceInterface;
1011
use Illuminate\Database\Eloquent\Model;
1112

1213
final readonly class TransferDtoAssembler implements TransferDtoAssemblerInterface
1314
{
1415
public function __construct(
15-
private UuidFactoryServiceInterface $uuidService
16+
private UuidFactoryServiceInterface $uuidService,
17+
private ClockServiceInterface $clockService,
1618
) {
1719
}
1820

@@ -34,7 +36,9 @@ public function create(
3436
$fromModel->getKey(),
3537
$toModel->getKey(),
3638
$discount,
37-
$fee
39+
$fee,
40+
$this->clockService->now(),
41+
$this->clockService->now(),
3842
);
3943
}
4044
}

src/Internal/Dto/TransactionDto.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
/** @immutable */
1010
final readonly class TransactionDto implements TransactionDtoInterface
1111
{
12-
private DateTimeImmutable $createdAt;
13-
14-
private DateTimeImmutable $updatedAt;
15-
1612
/**
1713
* @param array<mixed>|null $meta
1814
*/
@@ -24,10 +20,10 @@ public function __construct(
2420
private string $type,
2521
private float|int|string $amount,
2622
private bool $confirmed,
27-
private ?array $meta
23+
private ?array $meta,
24+
private DateTimeImmutable $createdAt,
25+
private DateTimeImmutable $updatedAt,
2826
) {
29-
$this->createdAt = new DateTimeImmutable();
30-
$this->updatedAt = new DateTimeImmutable();
3127
}
3228

3329
public function getUuid(): string

src/Internal/Dto/TransferDto.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
/** @immutable */
1010
final readonly class TransferDto implements TransferDtoInterface
1111
{
12-
private DateTimeImmutable $createdAt;
13-
14-
private DateTimeImmutable $updatedAt;
15-
1612
public function __construct(
1713
private string $uuid,
1814
private int $depositId,
@@ -21,10 +17,10 @@ public function __construct(
2117
private int $fromId,
2218
private int $toId,
2319
private int $discount,
24-
private string $fee
20+
private string $fee,
21+
private DateTimeImmutable $createdAt,
22+
private DateTimeImmutable $updatedAt,
2523
) {
26-
$this->createdAt = new DateTimeImmutable();
27-
$this->updatedAt = new DateTimeImmutable();
2824
}
2925

3026
public function getUuid(): string

0 commit comments

Comments
 (0)