-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CurrencyProviderInterface.php
52 lines (46 loc) · 1.36 KB
/
CurrencyProviderInterface.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
<?php
declare(strict_types=1);
namespace SonsOfPHP\Contract\Money;
/**
* Currency Provider.
*
* @author Joshua Estes <joshua@sonsofphp.com>
*/
interface CurrencyProviderInterface
{
/**
* Returns all of the currencies this Currency Provide will provide.
*
* @throw MoneyExceptionInterface
* This method may throw an exception if, for example it's making queries
* to a database, if it's unable to return any currencies
*
* @return CurrencyInterface[]
*/
public function getCurrencies(): iterable;
/**
* Pass in a currency object or a currency code (ie USD) and it
* will return true is the currency exists in this provider.
*
*
* @throw MoneyException
* @throw UnknownCurrencyException
*/
public function hasCurrency(CurrencyInterface|string $currency): bool;
/**
* Returns the currency or thows MoneyException is currency does not
* exist in this provider.
*
*
* @throw MoneyException
* @throw UnknownCurrencyException
*/
public function getCurrency(CurrencyInterface|string $currency): CurrencyInterface;
/**
* In case you need to run your own queries against this provider the query
* method will allow you to do this.
*
* @throw MoneyException
*/
public function query(CurrencyProviderQueryInterface $query);
}