-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathexample.php
More file actions
29 lines (20 loc) · 836 Bytes
/
example.php
File metadata and controls
29 lines (20 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
$loader = require __DIR__ . "/vendor/autoload.php";
use Leaphly\Price\Price;
use Leaphly\Price\Infrastructure\PricePresentation;
$price1 = new Price(
['EUR'=>100, 'GBP'=>100]
);
$price1 = $price1->multiply(10);
$price2 = new Price(
['EUR'=>100],
['EUR/GBP 1.100']
);
$priceSum = $price1->add($price2);
echo 'price1 = ' . PricePresentation::stringifyPrice($price1).'.'.PHP_EOL;
echo 'price2 = ' . PricePresentation::stringifyPrice($price2).'.'.PHP_EOL;
echo 'price1+price2 = ' . PricePresentation::stringifyPrice($priceSum).'.'.PHP_EOL;
echo 'the amount in EUR:'.$priceSum->inEUR().'.'.PHP_EOL;
echo 'the amount in GBP:'.$priceSum->inGBP().'.'.PHP_EOL;
echo 'is Zero?'.($price1->isZero()?' true':' false').'.'.PHP_EOL;
echo 'is price1 equals to price2?'.($price1->equals($price2)?' true':' false').'.'.PHP_EOL;