These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 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 | function __construct(\SimpleXMLElement $xmlElement = null, \DateTime $date = null) |
||
| 58 | { |
||
| 59 | if (!is_null($xmlElement)) { |
||
| 60 | $this->id = (int)$xmlElement->attributes()[0]; |
||
| 61 | $this->numCode = (string)$xmlElement->NumCode; |
||
|
0 ignored issues
–
show
|
|||
| 62 | $this->charCode = (string)$xmlElement->CharCode; |
||
| 63 | $this->name = (string)($xmlElement->Name ? $xmlElement->Name : $xmlElement->QuotName); |
||
| 64 | $this->scale = (int)$xmlElement->Scale; |
||
| 65 | $this->rate = (float)$xmlElement->Rate; |
||
| 66 | } |
||
| 67 | |||
| 68 | if ($date) { |
||
| 69 | $this->date = $date; |
||
| 70 | } |
||
| 71 | } |
||
| 72 | |||
| 73 | |||
| 74 | /** |
||
| 75 | * @return int |
||
| 76 | */ |
||
| 77 | public function getId() |
||
| 78 | { |
||
| 79 | return $this->id; |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @return int |
||
| 84 | */ |
||
| 85 | public function getNumCode() |
||
| 86 | { |
||
| 87 | return $this->numCode; |
||
| 88 | } |
||
| 89 | |||
| 90 | |||
| 91 | /** |
||
| 92 | * @return string |
||
| 93 | */ |
||
| 94 | public function getCharCode() |
||
| 95 | { |
||
| 96 | return $this->charCode; |
||
| 97 | } |
||
| 98 | |||
| 99 | /** |
||
| 100 | * @return string |
||
| 101 | */ |
||
| 102 | public function getName() |
||
| 103 | { |
||
| 104 | return $this->name; |
||
| 105 | } |
||
| 106 | |||
| 107 | /** |
||
| 108 | * @return float |
||
| 109 | */ |
||
| 110 | public function getRate() |
||
| 111 | { |
||
| 112 | return $this->rate; |
||
| 113 | } |
||
| 114 | |||
| 115 | /** |
||
| 116 | * @return int |
||
| 117 | */ |
||
| 118 | public function getScale() |
||
| 119 | { |
||
| 120 | return $this->scale; |
||
| 121 | } |
||
| 122 | |||
| 123 | /** |
||
| 124 | * @return \DateTime |
||
| 125 | */ |
||
| 126 | public function getDate() |
||
| 127 | { |
||
| 128 | return $this->date; |
||
| 129 | } |
||
| 130 | |||
| 131 | |||
| 132 | } |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.