Skip to content

Commit

Permalink
format currency
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivascu Madalin committed Nov 28, 2023
1 parent b194775 commit b5373e1
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/Services/ActiveSubscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,31 @@ private function format($data): array
foreach ($decoded as $subscription) {
$formatedSubscription = [];
foreach ($subscription as $key => $subscriptionData) {
$formatedSubscription[lcfirst($key)] = $subscriptionData;
$camelKey = lcfirst($key);
$formatedSubscription[$camelKey] = $this->formatValue($camelKey, $subscriptionData);
}
$formated[] = $formatedSubscription;
}
return $formated;
}

/**
* Format value for currency
*
* @param string $key
* @param string|array $value
*
* @return string|array
*/
private function formatValue($key, $value)
{
if ($key === 'currencies') {
$value = $value["string"];
if (is_string($value)) {
$value = [$value];
}
}

return $value;
}
}

0 comments on commit b5373e1

Please sign in to comment.