Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
orkhanahmadov committed Sep 22, 2020
2 parents 1a4bdcf + c3d76de commit caa385a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [orkhanahmadov]
8 changes: 4 additions & 4 deletions src/CBAR.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function __get(string $currency)
}

if (! isset($this->rates[$this->date][$currency])) {
throw new CurrencyException('Currency with '.$currency.' code is not available');
throw new CurrencyException('Currency with ' . $currency . ' code is not available');
}

if ($this->aznAmount) {
Expand Down Expand Up @@ -197,7 +197,7 @@ public function __call(string $currency, array $arguments)
}

if (! isset($this->rates[$this->date][$currency])) {
throw new CurrencyException('Currency with '.$currency.' code is not available');
throw new CurrencyException('Currency with ' . $currency . ' code is not available');
}

return $this->$currency * ($arguments[0] ?? 1);
Expand Down Expand Up @@ -225,11 +225,11 @@ public function AZN($amount = 1)
private function getRatesFromCBAR()
{
if (! $validatedDate = strtotime($this->date)) {
throw new DateException($this->date.' is not a valid date.');
throw new DateException($this->date . ' is not a valid date.');
}
$this->date = date('d.m.Y', $validatedDate);

$response = $this->client->get('https://www.cbar.az/currencies/'.$this->date.'.xml');
$response = $this->client->get('https://www.cbar.az/currencies/' . $this->date . '.xml');

$xml = simplexml_load_string($response->getBody()->getContents());

Expand Down
16 changes: 8 additions & 8 deletions tests/Unit/CBARTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function invalidDates()
public function test_initializing_class_with_invalid_date_throws_exception($date)
{
$this->expectException(DateException::class);
$this->expectExceptionMessage($date.' is not a valid date.');
$this->expectExceptionMessage($date . ' is not a valid date.');

(new CBAR($date))->EUR;
}
Expand All @@ -44,7 +44,7 @@ public function test_initializing_class_with_invalid_date_throws_exception($date
public function test_passing_invalid_date_to_for_method_throws_exception($date)
{
$this->expectException(DateException::class);
$this->expectExceptionMessage($date.' is not a valid date.');
$this->expectExceptionMessage($date . ' is not a valid date.');

$cbar = new CBAR();
$cbar->for($date);
Expand All @@ -57,7 +57,7 @@ public function test_for_sets_currencies_from_cbar()
$this->guzzler
->expects($this->once())
->get('https://www.cbar.az/currencies/01.05.2019.xml')
->willRespond(new Response(200, [], file_get_contents(__DIR__.'/../dummy_response.xml')));
->willRespond(new Response(200, [], file_get_contents(__DIR__ . '/../dummy_response.xml')));
$this->assertEmpty($cbar->getRates());

$cbar->for('01.05.2019');
Expand All @@ -72,7 +72,7 @@ public function test_guzzle_will_not_fetch_cbar_api_if_rates_for_given_date_are_
$this->guzzler
->expects($this->once())
->get('https://www.cbar.az/currencies/01.05.2019.xml')
->willRespond(new Response(200, [], file_get_contents(__DIR__.'/../dummy_response.xml')));
->willRespond(new Response(200, [], file_get_contents(__DIR__ . '/../dummy_response.xml')));

$cbar->for('01.05.2019');
$cbar->for('01.05.2019');
Expand Down Expand Up @@ -116,8 +116,8 @@ public function test_method_get_method_get_rates_from_cbar_if_rates_for_given_da
$cbar->setClient($this->guzzler->getClient());
$this->guzzler
->expects($this->once())
->get('https://www.cbar.az/currencies/'.date('d.m.Y').'.xml')
->willRespond(new Response(200, [], file_get_contents(__DIR__.'/../dummy_response.xml')));
->get('https://www.cbar.az/currencies/' . date('d.m.Y') . '.xml')
->willRespond(new Response(200, [], file_get_contents(__DIR__ . '/../dummy_response.xml')));
$this->assertEmpty($cbar->getRates());

$cbar->USD;
Expand Down Expand Up @@ -161,8 +161,8 @@ public function test_method_set_method_get_rates_from_cbar_if_rates_for_given_da
$cbar->setClient($this->guzzler->getClient());
$this->guzzler
->expects($this->once())
->get('https://www.cbar.az/currencies/'.date('d.m.Y').'.xml')
->willRespond(new Response(200, [], file_get_contents(__DIR__.'/../dummy_response.xml')));
->get('https://www.cbar.az/currencies/' . date('d.m.Y') . '.xml')
->willRespond(new Response(200, [], file_get_contents(__DIR__ . '/../dummy_response.xml')));
$this->assertEmpty($cbar->getRates());

$cbar->USD(100);
Expand Down

0 comments on commit caa385a

Please sign in to comment.