Skip to content

Commit 67c5623

Browse files
committed
Tweak conversion code
1 parent 4d00656 commit 67c5623

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

src/ECBConverter.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function list(bool $asArray = false): array
7575
* @return float[]|float
7676
* @throws ECBException
7777
*/
78-
public function convert(float $amount, $currencies, callable $callback)
78+
private function convert(float $amount, $currencies, callable $callback)
7979
{
8080
$this->check();
8181

@@ -135,19 +135,14 @@ public function toEuro(float $amount, $currencies, ?int $precision = null)
135135
public function toForeign(float $amount, $currencies, ?int $precision = null)
136136
{
137137
return $this->convert($amount, $currencies, function ($amount, $rate) use ($precision) {
138-
$val = $amount * $rate;
139-
return !is_null($precision) ? round($val, $precision) : $val;
140-
});
141-
}
138+
$value = $amount * $rate;
142139

143-
/**
144-
* Reloads ECB exchange references
145-
*
146-
* @throws ECBException
147-
*/
148-
public function reloadExchangeReferences(ECB $ecb): void
149-
{
150-
$this->exchange_data = $ecb->getExchangeReferences();
140+
if (!is_null($precision)) {
141+
return round($value, $precision);
142+
} else {
143+
return $value;
144+
}
145+
});
151146
}
152147

153148
public function getECB(): ECB

0 commit comments

Comments
 (0)