public static function stringifyPrice(Price $price) { $moneyArray = $price->toArray(); array_walk($moneyArray, function (Money &$money) { $money = (string) $money->getCurrency() . ' ' . $money->getAmount(); return $money; }); $conversionsArray = $price->getConversions(); array_walk($conversionsArray, function (CurrencyPair &$conversion) { $conversion = (string) $conversion->getBaseCurrency() . '/' . (string) $conversion->getCounterCurrency() . ' ' . $conversion->getRatio(); return $conversion; }); $output = implode(',', $moneyArray); if (count($conversionsArray) > 0) { $output .= ';' . implode(',', $conversionsArray); } return $output; }
public function testMultiplyPrices() { $price = new Price(['EUR' => 10, 'USD' => 10]); $this->assertEquals(20, $price->multiply(2)->getAmount('EUR')); }