unapi / helper-money
Unapi helper: money
Installs: 4 547
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/unapi/helper-money
Requires
- php: >=7.1.0
- unapi/helper-types: ^1.0
Requires (Dev)
- phpunit/phpunit: ^11.5
README
PHP implementation for the MoneyAmount pattern.
Installation
With composer:
composer require unapi/helper-money
Usage
Create Money amount:
use unapi\helper\money\MoneyAmount; use unapi\helper\money\Currency; $money = new MoneyAmount(20.0, new Currency(Currency::EUR));
Create wallet:
use unapi\helper\money\Wallet; use unapi\helper\money\MoneyAmount; use unapi\helper\money\Currency; $wallet = new Wallet([ new MoneyAmount(20.0, new Currency(Currency::EUR)) new MoneyAmount(10.0, new Currency(Currency::USD)) ]); $newWallet = $wallet->addMoney( new MoneyAmount(5.0, new Currency(Currency::EUR)) );