1 | <?php |
||
2 | declare(strict_types=1); |
||
3 | |||
4 | namespace Shoman4eg\Nalog\DTO; |
||
5 | |||
6 | use Brick\Math\BigDecimal; |
||
7 | |||
8 | /** |
||
9 | * @author Artem Dubinin <[email protected]> |
||
10 | */ |
||
11 | final class IncomeServiceItem implements \JsonSerializable |
||
12 | { |
||
13 | private string $name; |
||
14 | |||
15 | /** @var float|int|string */ |
||
16 | private $amount; |
||
17 | |||
18 | /** @var float|int */ |
||
19 | private $quantity; |
||
20 | |||
21 | /** |
||
22 | * @param float|int|string $amount |
||
23 | * @param float|int $quantity |
||
24 | */ |
||
25 | public function __construct(string $name, $amount, $quantity) |
||
26 | { |
||
27 | $this->name = $name; |
||
28 | $this->amount = $amount; |
||
29 | $this->quantity = $quantity; |
||
30 | } |
||
31 | |||
32 | public function jsonSerialize(): array |
||
33 | { |
||
34 | return [ |
||
35 | 'name' => $this->name, |
||
36 | 'amount' => $this->amount, |
||
37 | 'quantity' => $this->quantity, |
||
38 | ]; |
||
39 | } |
||
40 | |||
41 | public function getName(): string |
||
42 | { |
||
43 | return $this->name; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return float|int|string |
||
48 | */ |
||
49 | public function getAmount() |
||
50 | { |
||
51 | return $this->amount; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return float|int |
||
56 | */ |
||
57 | public function getQuantity() |
||
58 | { |
||
59 | return $this->quantity; |
||
60 | } |
||
61 | |||
62 | public function getTotalAmount(): BigDecimal |
||
63 | { |
||
64 | return BigDecimal::of($this->amount) |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
65 | ->multipliedBy($this->quantity) |
||
66 | ; |
||
67 | } |
||
68 | } |
||
69 |