diff --git a/src/Helper/CurrencyFormatter.php b/src/Helper/CurrencyFormatter.php index 7672eb5347..83f5c4cf39 100644 --- a/src/Helper/CurrencyFormatter.php +++ b/src/Helper/CurrencyFormatter.php @@ -7,6 +7,22 @@ use Commercetools\Core\Model\Common\Context; +/** + * Formats a given currency for display. As default the intl extensions capabilities are used for formatting. + * Given the locale of the context and the currency, the amount will be formatted with intl NumberFormatter. + * The formatter reads the fraction digits from the formatter for the given currency and locale. This information + * is used to calculate the currency value from the centAmount + * + * Example: + * $centAmount = 123456; + * $currency = 'JPY'; + * $str = $this->format($centAmount, $currency); // '¥123,456' + * $currency = 'USD'; + * $str = $this->format($centAmount, $currency); // '$1,234.56' + * $currency = 'EUR'; + * $str = $this->format($centAmount, $currency); // '1.234,56 €' + * @package Commercetools\Core\Helper + */ class CurrencyFormatter { protected $context; diff --git a/src/Model/Common/Collection.php b/src/Model/Common/Collection.php index bc7ce75a32..c374889bed 100644 --- a/src/Model/Common/Collection.php +++ b/src/Model/Common/Collection.php @@ -130,6 +130,8 @@ public function toArray() foreach ($this->typeData as $key => $value) { if ($value instanceof JsonDeserializeInterface) { $values[$key] = $value->toArray(); + } else { + $values[$key] = $value; } }