Balance   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 83
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A fromResponse() 0 11 1
A setCard() 0 6 1
A getCard() 0 4 1
A setBalance() 0 6 1
A getBalance() 0 4 1
A setBalanceDate() 0 6 1
A getBalanceDate() 0 4 1
1
<?php
2
3
namespace Mukhin\PrivatbankBundle\Model;
4
5
class Balance
6
{
7
    /** @var Card */
8
    protected $card;
9
10
    /** @var float */
11
    protected $balance;
12
13
    /** @var \DateTime */
14
    protected $balanceDate;
15
16
    public static function fromResponse(\SimpleXMLElement $cardBalance)
17
    {
18
        return (new self)
19
            ->setCard(Card::fromResponse($cardBalance->card))
20
            ->setBalance(floatval((string)$cardBalance->balance))
21
            ->setBalanceDate(new \DateTime(
22
                $cardBalance->balanceDate,
23
                new \DateTimeZone('Europe/Kiev')
24
            ))
25
        ;
26
    }
27
28
    /**
29
     * @param Card $card
30
     *
31
     * @return $this
32
     */
33
    public function setCard($card)
34
    {
35
        $this->card = $card;
36
37
        return $this;
38
    }
39
40
    /**
41
     * @return Card
42
     */
43
    public function getCard()
44
    {
45
        return $this->card;
46
    }
47
48
    /**
49
     * @param float $balance
50
     *
51
     * @return $this
52
     */
53
    public function setBalance($balance)
54
    {
55
        $this->balance = $balance;
56
57
        return $this;
58
    }
59
60
    /**
61
     * @return float
62
     */
63
    public function getBalance()
64
    {
65
        return $this->balance;
66
    }
67
68
    /**
69
     * @param \DateTime $balanceDate
70
     *
71
     * @return $this
72
     */
73
    public function setBalanceDate(\DateTime $balanceDate)
74
    {
75
        $this->balanceDate = $balanceDate;
76
77
        return $this;
78
    }
79
80
    /**
81
     * @return \DateTime
82
     */
83
    public function getBalanceDate()
84
    {
85
        return $this->balanceDate;
86
    }
87
}