ExchangeRate   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 139
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 10
lcom 0
cbo 0
dl 0
loc 139
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A createFromXML() 0 12 2
A getId() 0 4 1
A getNumCode() 0 4 1
A getCharCode() 0 4 1
A getName() 0 4 1
A getRate() 0 4 1
A getScale() 0 4 1
A getDate() 0 4 1
1
<?php
2
/**
3
 * (c) itmedia.by <[email protected]>
4
 */
5
6
namespace Submarine\NbrbExchangeRatesBundle;
7
8
/**
9
 * Курс обмена
10
 * Class ExchangeRate
11
 * @package Submarine\NbrbParserBundle
12
 */
13
class ExchangeRate
14
{
15
16
    /**
17
     * Внутренний код валюты
18
     * @var int
19
     */
20
    private $id;
21
22
    /**
23
     * цифровой код
24
     * @var int
25
     */
26
    private $numCode;
27
28
    /**
29
     * буквенный код
30
     * @var string
31
     */
32
    private $charCode;
33
34
    /**
35
     * номинал
36
     * @var int
37
     */
38
    private $scale;
39
40
    /**
41
     * наименование валюты
42
     * @var string
43
     */
44
    private $name;
45
46
    /**
47
     * курс
48
     * @var float
49
     */
50
    private $rate;
51
52
    /**
53
     * @var \DateTime
54
     */
55
    private $date;
56
57
    /**
58
     * ExchangeRate constructor.
59
     * @param int $id
60
     * @param int $numCode
61
     * @param string $charCode
62
     * @param int $scale
63
     * @param string $name
64
     * @param float $rate
65
     * @param \DateTime $date
66
     */
67
    public function __construct($id, $numCode, $charCode, $scale, $name, $rate, \DateTime $date)
68
    {
69
        $this->id = $id;
70
        $this->numCode = $numCode;
71
        $this->charCode = $charCode;
72
        $this->scale = $scale;
73
        $this->name = $name;
74
        $this->rate = $rate;
75
        $this->date = $date;
76
    }
77
78
79
    static public function createFromXML(\SimpleXMLElement $xmlElement = null, \DateTime $date)
80
    {
81
        return new ExchangeRate(
82
            (int)$xmlElement->attributes()[0],
0 ignored issues
show
Bug introduced by
It seems like $xmlElement is not always an object, but can also be of type null. Maybe add an additional type check?

If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:

function someFunction(A $objectMaybe = null)
{
    if ($objectMaybe instanceof A) {
        $objectMaybe->doSomething();
    }
}
Loading history...
83
            (int)$xmlElement->NumCode,
84
            (string)$xmlElement->CharCode,
85
            (int)$xmlElement->Scale,
86
            (string)($xmlElement->Name ?: $xmlElement->QuotName),
87
            (float)$xmlElement->Rate,
88
            $date
89
        );
90
    }
91
92
93
    /**
94
     * @return int
95
     */
96
    public function getId()
97
    {
98
        return $this->id;
99
    }
100
101
    /**
102
     * @return int
103
     */
104
    public function getNumCode()
105
    {
106
        return $this->numCode;
107
    }
108
109
110
    /**
111
     * @return string
112
     */
113
    public function getCharCode()
114
    {
115
        return $this->charCode;
116
    }
117
118
    /**
119
     * @return string
120
     */
121
    public function getName()
122
    {
123
        return $this->name;
124
    }
125
126
    /**
127
     * @return float
128
     */
129
    public function getRate()
130
    {
131
        return $this->rate;
132
    }
133
134
    /**
135
     * @return int
136
     */
137
    public function getScale()
138
    {
139
        return $this->scale;
140
    }
141
142
    /**
143
     * @return \DateTime
144
     */
145
    public function getDate()
146
    {
147
        return $this->date;
148
    }
149
150
151
}