-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCurrencyDriverContract.php
More file actions
83 lines (64 loc) · 2.18 KB
/
CurrencyDriverContract.php
File metadata and controls
83 lines (64 loc) · 2.18 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
declare(strict_types=1);
namespace Otherguy\Currency\Drivers;
use DateTimeInterface;
use Otherguy\Currency\Currency;
use Otherguy\Currency\Results\ConversionResult;
interface CurrencyDriverContract
{
public function source(string|Currency $baseCurrency): static;
public function from(string|Currency $baseCurrency): static;
/**
* @param string|Currency|array<int, string|Currency> $symbols
*/
public function currencies(string|Currency|array $symbols = []): static;
/**
* @param string|Currency|array<int, string|Currency> $symbols
*/
public function to(string|Currency|array $symbols = []): static;
public function amount(?float $amount): static;
public function date(?DateTimeInterface $date): static;
/**
* Returns the date in 'YYYY-mm-dd' format or null if not set.
*/
public function getDate(): ?string;
/**
* @return list<string>
*/
public function getSymbols(): array;
/**
* @param string|Currency|array<int, string|Currency> $forCurrency
*/
public function get(string|Currency|array $forCurrency = []): ConversionResult;
/**
* Converts an amount of `$fromCurrency` into `$toCurrency`, optionally for a given date.
*/
public function convert(
?float $amount = null,
string|Currency|null $fromCurrency = null,
string|Currency|null $toCurrency = null,
?DateTimeInterface $date = null,
): ConversionResult;
/**
* @param string|Currency|array<int, string|Currency> $forCurrency
*/
public function historical(
?DateTimeInterface $date = null,
string|Currency|array $forCurrency = [],
): ConversionResult;
public function getBaseCurrency(): string;
public function config(string $key, string $value): static;
/**
* Sets the API key to use.
*
* Shortcut for config('access_key', $accessKey).
*/
public function accessKey(string $accessKey): static;
/**
* Switches all HTTP requests to HTTPS.
*
* Drivers default to HTTPS in 2.0; this exists for explicit toggling.
*/
public function secure(): static;
public function getProtocol(): string;
}