Passed
Push — master ( e11425...a29639 )
by Artem
09:19 queued 07:41
created

IncomeServiceItem::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
    private $amount;
15
    private $quantity;
16
17
    /**
18
     * @param float|int|string $amount
19
     * @param float|int        $quantity
20
     */
21
    public function __construct(string $name, $amount, $quantity)
22
    {
23
        $this->name = $name;
24
        $this->amount = $amount;
25
        $this->quantity = $quantity;
26
    }
27
28
    public function jsonSerialize(): array
29
    {
30
        return [
31
            'name' => $this->name,
32
            'amount' => $this->amount,
33
            'quantity' => $this->quantity,
34
        ];
35
    }
36
37
    public function getName(): string
38
    {
39
        return $this->name;
40
    }
41
42
    /**
43
     * @return float|int|string
44
     */
45
    public function getAmount()
46
    {
47
        return $this->amount;
48
    }
49
50
    /**
51
     * @return float|int
52
     */
53
    public function getQuantity()
54
    {
55
        return $this->quantity;
56
    }
57
58
    public function getTotalAmount(): BigDecimal
59
    {
60
        return BigDecimal::of($this->amount)
0 ignored issues
show
Bug Best Practice introduced by
The expression return Brick\Math\BigDec...liedBy($this->quantity) could return the type Brick\Math\BigInteger|Brick\Math\BigRational which is incompatible with the type-hinted return Brick\Math\BigDecimal. Consider adding an additional type-check to rule them out.
Loading history...
61
            ->multipliedBy($this->quantity)
62
        ;
63
    }
64
}
65