Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
fix(Collection): fix serialization of collection with primitive types
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Schulze committed Nov 5, 2015
1 parent e8d058b commit 0e1251f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Helper/CurrencyFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/Model/Common/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 0e1251f

Please # to comment.