Skip to content

Commit d220c64

Browse files
committed
support immutable carbon
1 parent 1b9e638 commit d220c64

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

src/Facades/Forex.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
use Brick\Math\RoundingMode;
88
use Brick\Money\Currency;
99
use Brick\Money\Money;
10-
use Carbon\Carbon;
10+
use Carbon\CarbonInterface;
1111
use Illuminate\Support\Facades\Facade;
1212

1313
/**
1414
* @method static array<string, int|float> latest(string $currency)
15-
* @method static array<string, int|float> rates(Carbon $date, string $currency)
15+
* @method static array<string, int|float> rates(CarbonInterface $date, string $currency)
1616
* @method static array<string, int|float> refreshLatest()
1717
* @method static array<string, int|float> queryLatest()
1818
* @method static array<string, int|float> refreshRates()
1919
* @method static array<string, int|float> queryRates()
2020
* @method static array<string, array<string, int|float>> getLatest()
2121
* @method static array<string, array<string, array<string, int|float>>> getRates()
22-
* @method static Money convert(Money $money, string|Currency $currency, RoundingMode $roundingMode = RoundingMode::HALF_UP, ?Carbon $date = null)
22+
* @method static Money convert(Money $money, string|Currency $currency, RoundingMode $roundingMode = RoundingMode::HALF_UP, ?CarbonInterface $date = null)
2323
*
2424
* @see \Elegantly\Forex\Forex
2525
*/

src/Forex.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Brick\Money\ExchangeRateProvider\BaseCurrencyProvider;
1111
use Brick\Money\ExchangeRateProvider\ConfigurableProvider;
1212
use Brick\Money\Money;
13-
use Carbon\Carbon;
13+
use Carbon\CarbonInterface;
1414

1515
class Forex
1616
{
@@ -41,7 +41,7 @@ public function latest(string $currency): array
4141
/**
4242
* @return array<string, int|float>
4343
*/
44-
public function rates(Carbon $date, string $currency): array
44+
public function rates(CarbonInterface $date, string $currency): array
4545
{
4646
$datetime = $date->format('Y-m-d');
4747

@@ -67,7 +67,7 @@ public function queryLatest(string $currency): array
6767
/**
6868
* @return array<string, int|float>
6969
*/
70-
public function refreshRates(Carbon $date, string $currency): array
70+
public function refreshRates(CarbonInterface $date, string $currency): array
7171
{
7272
$datetime = $date->format('Y-m-d');
7373

@@ -77,7 +77,7 @@ public function refreshRates(Carbon $date, string $currency): array
7777
/**
7878
* @return array<string, int|float>
7979
*/
80-
public function queryRates(Carbon $date, string $currency): array
80+
public function queryRates(CarbonInterface $date, string $currency): array
8181
{
8282
return $this->client->rates($date, $currency);
8383
}
@@ -107,7 +107,7 @@ public function convert(
107107
Money $money,
108108
string|Currency $currency,
109109
RoundingMode $roundingMode = RoundingMode::HALF_UP,
110-
?Carbon $date = null,
110+
?CarbonInterface $date = null,
111111
): Money {
112112

113113
$currency = is_string($currency) ? $currency : $currency->getCurrencyCode();

src/ForexClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Elegantly\Forex;
66

7-
use Carbon\Carbon;
7+
use Carbon\CarbonInterface;
88

99
interface ForexClient
1010
{
@@ -16,5 +16,5 @@ public function latest(string $currency): array;
1616
/**
1717
* @return array<string, int|float>
1818
*/
19-
public function rates(Carbon $carbon, string $currency): array;
19+
public function rates(CarbonInterface $carbon, string $currency): array;
2020
}

src/Integrations/ExchangeRateApi/ExchangeRateApiConnector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Elegantly\Forex\Integrations\ExchangeRateApi;
66

7-
use Carbon\Carbon;
7+
use Carbon\CarbonInterface;
88
use Elegantly\Forex\ForexClient;
99
use Elegantly\Forex\Integrations\ExchangeRateApi\Requests\HistoryRequest;
1010
use Elegantly\Forex\Integrations\ExchangeRateApiFree\Requests\LatestRequest;
@@ -103,7 +103,7 @@ public function latest(string $currency): array
103103
return $this->send(new LatestRequest($currency))->json('conversion_rates', []);
104104
}
105105

106-
public function rates(Carbon $date, string $currency): array
106+
public function rates(CarbonInterface $date, string $currency): array
107107
{
108108
// @phpstan-ignore-next-line
109109
return $this->send(new HistoryRequest($date, $currency))->json('conversion_rates', []);

src/Integrations/ExchangeRateApi/Requests/HistoryRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Elegantly\Forex\Integrations\ExchangeRateApi\Requests;
66

7-
use Carbon\Carbon;
7+
use Carbon\CarbonInterface;
88
use Saloon\Enums\Method;
99
use Saloon\Http\Request;
1010

@@ -13,7 +13,7 @@ class HistoryRequest extends Request
1313
protected Method $method = Method::GET;
1414

1515
public function __construct(
16-
protected readonly Carbon $date,
16+
protected readonly CarbonInterface $date,
1717
protected readonly string $currency,
1818
) {
1919
//

src/Integrations/ExchangeRateApiFree/ExchangeRateApiFreeConnector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Elegantly\Forex\Integrations\ExchangeRateApiFree;
66

7-
use Carbon\Carbon;
7+
use Carbon\CarbonInterface;
88
use Elegantly\Forex\ForexClient;
99
use Elegantly\Forex\Integrations\ExchangeRateApiFree\Requests\LatestRequest;
1010
use Exception;
@@ -92,7 +92,7 @@ public function latest(string $currency): array
9292
return $this->send(new LatestRequest($currency))->json('rates', []);
9393
}
9494

95-
public function rates(Carbon $date, string $currency): array
95+
public function rates(CarbonInterface $date, string $currency): array
9696
{
9797
throw new Exception(static::class.' does not support historical data.');
9898
}

0 commit comments

Comments
 (0)