Skip to content

PHP implementation of Martin Fowler's money pattern

License

Notifications You must be signed in to change notification settings

lhellemons/php-money

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Money pattern

Author: Laurens Hellemons lhellemons@gmail.com

Usage

Install the package using composer.

composer require lhellemons/php-money
<?php

use SolidPhp\Money\Money\Currency;
use SolidPhp\Money\Money\Money;

$price = Money::amountOf(100, Currency::EUR());
$vatPercentage = 0.30;
$priceWithVat = $price->times(1 + $vatPercentage);
$vatAmount = $priceWithVat->minus($price);

echo $price; // EUR 100
echo $priceWithVat; // EUR 130
echo $vatAmount; // EUR 30

echo $price->compareTo($priceWithVat); // -1
echo $price <=> $priceWithVat; // -1, be careful to use the same currency!

About

PHP implementation of Martin Fowler's money pattern

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages