Skip to content

Commit

Permalink
Fix invalid order of sprintf arguments in CurrencyExchangeRates - issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreyu committed Jun 8, 2021
1 parent 30c3649 commit 0ef092c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"webmozart/assert": "^1.0"
},
"require-dev": {
"ext-dom": "*",
"ext-mbstring": "*",
"guzzlehttp/psr7": "^1.2",
"http-interop/http-factory-guzzle": "^1.0",
"phpunit/phpunit": "^8.2.3",
Expand Down
14 changes: 7 additions & 7 deletions src/Api/CurrencyExchangeRates.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(ClientInterface $client, string $tableType, string $
Assert::notEmpty($currencyCode);
Assert::maxLength($currencyCode, 3);

$this->currencyCode = $currencyCode;
$this->currencyCode = strtolower($currencyCode);
}

/**
Expand All @@ -49,7 +49,7 @@ public function __construct(ClientInterface $client, string $tableType, string $
*/
public function all(): ResponseInterface
{
return $this->get(sprintf('exchangerates/rates/%s/%s', $this->currencyCode, $this->tableType));
return $this->get(sprintf('exchangerates/rates/%s/%s', $this->tableType, $this->currencyCode));
}

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

/**
Expand All @@ -74,7 +74,7 @@ public function latest(int $count): ResponseInterface
*/
public function today(): ResponseInterface
{
return $this->get(sprintf('exchangerates/rates/%s/%s/today', $this->currencyCode, $this->tableType));
return $this->get(sprintf('exchangerates/rates/%s/%s/today', $this->tableType, $this->currencyCode));
}

/**
Expand All @@ -90,8 +90,8 @@ public function inDate(DateTimeInterface $date): ResponseInterface
{
return $this->get(sprintf(
'exchangerates/rates/%s/%s/%s',
$this->currencyCode,
$this->tableType,
$this->currencyCode,
$date->format(self::DATE_FORMAT)
));
}
Expand All @@ -110,10 +110,10 @@ public function betweenDates(DateTimeInterface $startDate, DateTimeInterface $en
{
return $this->get(sprintf(
'exchangerates/rates/%s/%s/%s/%s',
$this->currencyCode,
$this->tableType,
$this->currencyCode,
$startDate->format(self::DATE_FORMAT),
$endDate->format(self::DATE_FORMAT)
));
}
}
}

0 comments on commit 0ef092c

Please sign in to comment.