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

BalanceReponse   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
c 1
b 0
f 0
dl 0
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getDate() 0 3 1
A getValue() 0 7 2
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