-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMoneyInterface.php
70 lines (52 loc) · 1.63 KB
/
MoneyInterface.php
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
declare(strict_types=1);
namespace SonsOfPHP\Contract\Money;
/**
* Money Interface.
*
* Main API for interactiving with Money
*
* @author Joshua Estes <joshua@sonsofphp.com>
*/
interface MoneyInterface // extends \JsonSerializable
{
public function getAmount(): AmountInterface;
public function getCurrency(): CurrencyInterface;
public function with(MoneyOperatorInterface $operator): self;
public function query(MoneyQueryInterface $query);
public function isEqualTo(self $money): bool;
/**
* Returns true if this is greater than that.
*/
public function isGreaterThan(self $money): bool;
public function isGreaterThanOrEqualTo(self $money): bool;
public function isLessThan(self $money): bool;
public function isLessThanOrEqualTo(self $money): bool;
public function isNegative(): bool;
public function isPositive(): bool;
public function isZero(): bool;
/**
* Adds amount to existing amount and returns a new MoneyInterface.
*
* @todo MoneyInterface|AmountInterface
*/
public function add(self $money): self;
/**
* Subtracts amount to existing amount and returns a new MoneyInterface.
*
* @todo MoneyInterface|AmountInterface
*/
public function subtract(self $money): self;
/**
* Multiple by multiplier and returns new MoneyInterface.
*
* @param int|float|string $multiplier
*/
public function multiply($multiplier): self;
/**
* Divide by divisor and returns new MoneyInterface.
*
* @param int|float|string $divisor
*/
public function divide($divisor): self;
}