Skip to content

Commit 0ef092c

Browse files
committed
Fix invalid order of sprintf arguments in CurrencyExchangeRates - issue #1
1 parent 30c3649 commit 0ef092c

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
"webmozart/assert": "^1.0"
2424
},
2525
"require-dev": {
26+
"ext-dom": "*",
27+
"ext-mbstring": "*",
2628
"guzzlehttp/psr7": "^1.2",
2729
"http-interop/http-factory-guzzle": "^1.0",
2830
"phpunit/phpunit": "^8.2.3",

src/Api/CurrencyExchangeRates.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(ClientInterface $client, string $tableType, string $
3838
Assert::notEmpty($currencyCode);
3939
Assert::maxLength($currencyCode, 3);
4040

41-
$this->currencyCode = $currencyCode;
41+
$this->currencyCode = strtolower($currencyCode);
4242
}
4343

4444
/**
@@ -49,7 +49,7 @@ public function __construct(ClientInterface $client, string $tableType, string $
4949
*/
5050
public function all(): ResponseInterface
5151
{
52-
return $this->get(sprintf('exchangerates/rates/%s/%s', $this->currencyCode, $this->tableType));
52+
return $this->get(sprintf('exchangerates/rates/%s/%s', $this->tableType, $this->currencyCode));
5353
}
5454

5555
/**
@@ -62,7 +62,7 @@ public function all(): ResponseInterface
6262
*/
6363
public function latest(int $count): ResponseInterface
6464
{
65-
return $this->get(sprintf('exchangerates/rates/%s/%s/last/%d', $this->currencyCode, $this->tableType, $count));
65+
return $this->get(sprintf('exchangerates/rates/%s/%s/last/%d', $this->tableType, $this->currencyCode, $count));
6666
}
6767

6868
/**
@@ -74,7 +74,7 @@ public function latest(int $count): ResponseInterface
7474
*/
7575
public function today(): ResponseInterface
7676
{
77-
return $this->get(sprintf('exchangerates/rates/%s/%s/today', $this->currencyCode, $this->tableType));
77+
return $this->get(sprintf('exchangerates/rates/%s/%s/today', $this->tableType, $this->currencyCode));
7878
}
7979

8080
/**
@@ -90,8 +90,8 @@ public function inDate(DateTimeInterface $date): ResponseInterface
9090
{
9191
return $this->get(sprintf(
9292
'exchangerates/rates/%s/%s/%s',
93-
$this->currencyCode,
9493
$this->tableType,
94+
$this->currencyCode,
9595
$date->format(self::DATE_FORMAT)
9696
));
9797
}
@@ -110,10 +110,10 @@ public function betweenDates(DateTimeInterface $startDate, DateTimeInterface $en
110110
{
111111
return $this->get(sprintf(
112112
'exchangerates/rates/%s/%s/%s/%s',
113-
$this->currencyCode,
114113
$this->tableType,
114+
$this->currencyCode,
115115
$startDate->format(self::DATE_FORMAT),
116116
$endDate->format(self::DATE_FORMAT)
117117
));
118118
}
119-
}
119+
}

0 commit comments

Comments
 (0)