Passed
Push — master ( e4848e...a58aea )
by Jhao
02:14
created

BalanceReponse::getValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Appwilio\RussianPostSDK\Dispatching\Endpoints\Services\Responses;
6
7
use JMS\Serializer\Annotation as JMS;
8
9
final class BalanceReponse
10
{
11
    /**
12
     * @JMS\Type("float")
13
     * @var float
14
     */
15
    private $balance;
16
17
    /**
18
     * @JMS\SerializedName("balance-date")
19
     * @JMS\Type("DateTimeImmutable<'Y-m-d'>")
20
     * @var \DateTimeImmutable
21
     */
22
    private $date;
23
24
    /**
25
     * @JMS\SerializedName("work-with-balance")
26
     * @JMS\Type("bool")
27
     * @var bool
28
     */
29
    private $withBalance;
30
31
    /**
32
     * @JMS\SerializedName("error-message")
33
     * @JMS\Type("string")
34
     * @var string
35
     */
36
    private $error;
37
38
    public function getValue(): float
39
    {
40
        if ($this->withBalance) {
41
            return $this->balance;
42
        }
43
44
        throw new \Exception($this->error);
45
    }
46
47
    public function getDate(): \DateTimeImmutable
48
    {
49
        return $this->date;
50
    }
51
}
52