Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
DepositDto
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 fromDeposit
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
 jsonSerialize
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Dto;
6
7use App\Entity\Deposit;
8use JsonSerializable;
9
10final readonly class DepositDto implements JsonSerializable
11{
12    public function __construct(
13        public ?int $id,
14        public string $amount,
15        public string $document,
16        public string $date,
17        public ?int $entity,
18    ) {}
19
20    public static function fromDeposit(Deposit $deposit): self
21    {
22        return new self(
23            id: $deposit->getId(),
24            amount: $deposit->getAmount(),
25            document: $deposit->getDocument(),
26            date: $deposit->getDate()->format('Y-m-d'),
27            entity: $deposit->getEntity()->getId(),
28        );
29    }
30
31    /**
32     * @return array{id: int|null, amount: string, document: string, date: string, entity: int|null}
33     */
34    public function jsonSerialize(): array
35    {
36        return [
37            'id' => $this->id,
38            'amount' => $this->amount,
39            'document' => $this->document,
40            'date' => $this->date,
41            'entity' => $this->entity,
42        ];
43    }
44}