| Conditions | 2 |
| Paths | 2 |
| Total Lines | 17 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 36 | 27 | public function hydrateXml(\SimpleXMLElement $xml) |
|
| 37 | { |
||
| 38 | 27 | $currency = (int)$xml->Amount['currency']; |
|
| 39 | 27 | $alphaCurrency = AltaPay\alphaCurrencyFromNumeric($currency); |
|
| 40 | |||
| 41 | 27 | $this->id = (string)$xml->Id; |
|
| 42 | 27 | $this->amount = AltaPay\createMoneyFromFloat($alphaCurrency, (float)$xml->Amount); |
|
| 43 | 27 | $this->amountCurrency = $currency; |
|
| 44 | 27 | $this->type = (string)$xml->Type; |
|
| 45 | |||
| 46 | 27 | $this->date = \DateTimeImmutable::createFromFormat(DATE_RFC3339, (string)$xml->Date); |
|
| 47 | 27 | if ($this->date === false) { |
|
| 48 | 3 | $exception = new XmlException('The date format is wrong'); |
|
| 49 | 3 | $exception->setXmlElement($xml); |
|
| 50 | 3 | throw $exception; |
|
| 51 | } |
||
| 52 | 24 | } |
|
| 53 | |||
| 94 |