Changeset View
Changeset View
Standalone View
Standalone View
src/app/Wallet.php
Show First 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | class Wallet extends Model | ||||
* @return int | * @return int | ||||
*/ | */ | ||||
public function expectedCharges() | public function expectedCharges() | ||||
{ | { | ||||
return $this->chargeEntitlements(false); | return $this->chargeEntitlements(false); | ||||
} | } | ||||
/** | /** | ||||
* A helper to display human-readable amount of money using | |||||
* the wallet currency and specified locale. | |||||
* | |||||
* @param int $amount A amount of money (in cents) | |||||
* @param string $locale A locale for the output | |||||
* | |||||
* @return string String representation, e.g. "9.99 CHF" | |||||
*/ | |||||
public function money(int $amount, $locale = 'de_DE') | |||||
{ | |||||
$amount = round($amount / 100, 2); | |||||
// Prefer intl extension's number formatter | |||||
if (class_exists('NumberFormatter')) { | |||||
$nf = new \NumberFormatter($locale, \NumberFormatter::DECIMAL); | |||||
return $nf->formatCurrency($amount, $this->currency); | |||||
} | |||||
return sprintf('%.2f %s', $amount, $this->currency); | |||||
} | |||||
/** | |||||
* Remove a controller from this wallet. | * Remove a controller from this wallet. | ||||
* | * | ||||
* @param \App\User $user The user to remove as a controller from this wallet. | * @param \App\User $user The user to remove as a controller from this wallet. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function removeController(User $user) | public function removeController(User $user) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |