Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dostrog committed Feb 20, 2021
2 parents 5d3c36b + 88e963a commit f754254
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .php_cs.cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"php":"8.0.1","version":"2.18.2","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"ordered_imports":{"sortAlgorithm":"alpha"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline_array":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":["method"]},"single_trait_insert_per_statement":true},"hashes":{"src\/Services\/RussianCentralBank.php":1671965386,"src\/Services\/NationalBankOfUkraine.php":2535570899,"src\/Contracts\/ExchangeRate.php":3902066422,"src\/Contracts\/ExchangeRateService.php":3927293648,"src\/Contracts\/CurrencyPair.php":437577022,"src\/Contracts\/ExchangeRateProvider.php":3118380280,"src\/ExchangeRate.php":4270094098,"src\/StringHelper.php":2942084845,"src\/CurrencyPair.php":1763396578,"src\/CacheHelper.php":52867920,"src\/Commands\/InstallLarate.php":50923403,"src\/Larate.php":1802032553,"src\/Validation.php":3142905928,"src\/Providers\/LarateServiceProvider.php":2908215701,"src\/Facades\/LarateFacade.php":865551714,"tests\/TestCase.php":1723533337,"tests\/Feature\/LarateTest.php":2497438291,"tests\/Unit\/CurrencyPairTest.php":3497513797,"tests\/Unit\/ExchangeRateTest.php":145773214,"tests\/Unit\/CacheTest.php":1165793876,"tests\/Unit\/ValidationTest.php":2683340759,"tests\/Unit\/InstallLarateTest.php":3607283650,"tests\/Unit\/RussianCentralBankTest.php":2433905653,"tests\/Unit\/StringHelperTest.php":1154401536,"tests\/Unit\/NationalBankOfUkraineTest.php":1722701766,"src\/Exceptions\/InvalidArgumentException.php":1170491362,"src\/Services\/HttpService.php":2049481965}}
{"php":"8.0.1","version":"2.18.2","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"ordered_imports":{"sortAlgorithm":"alpha"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline_array":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":["method"]},"single_trait_insert_per_statement":true},"hashes":{"src\/Services\/RussianCentralBank.php":1709884715,"src\/Services\/NationalBankOfUkraine.php":3813385838,"src\/Contracts\/ExchangeRate.php":3833154505,"src\/Contracts\/ExchangeRateService.php":3585841511,"src\/Contracts\/CurrencyPair.php":2615292405,"src\/Contracts\/ExchangeRateProvider.php":643168451,"src\/ExchangeRate.php":4270094098,"src\/StringHelper.php":3041109882,"src\/CurrencyPair.php":151624525,"src\/CacheHelper.php":94839566,"src\/Commands\/InstallLarate.php":50923403,"src\/Larate.php":1823872682,"src\/Validation.php":1165504559,"src\/Providers\/LarateServiceProvider.php":2908215701,"src\/Facades\/LarateFacade.php":865551714,"tests\/TestCase.php":1723533337,"tests\/Feature\/LarateTest.php":2831933830,"tests\/Unit\/CurrencyPairTest.php":1587544825,"tests\/Unit\/ExchangeRateTest.php":904361737,"tests\/Unit\/CacheTest.php":3969626799,"tests\/Unit\/ValidationTest.php":2304374970,"tests\/Unit\/InstallLarateTest.php":602608481,"tests\/Unit\/RussianCentralBankTest.php":2924737037,"tests\/Unit\/StringHelperTest.php":1586094413,"tests\/Unit\/NationalBankOfUkraineTest.php":2566154181,"src\/Exceptions\/InvalidArgumentException.php":1170491362,"src\/Services\/HttpService.php":646674303}}
3 changes: 2 additions & 1 deletion src/Larate.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ public function getExchangeRate(CurrencyPairContract $currencyPair, DateTimeInte

return $rate;
}

public static function createForBaseCurrency(string $baseCurrency = 'RUB', CacheInterface $cache = null): Larate
{
$serviceClass = isset(config('larate.service')[$baseCurrency]) && class_exists(config('larate.service')[$baseCurrency])
? config('larate.service.' . $baseCurrency)
: config('larate.service.RUB');

return new self( new $serviceClass,$cache ?? app()->make('cache.store') );
return new self(new $serviceClass, $cache ?? app()->make('cache.store'));
}
}
1 change: 1 addition & 0 deletions src/Services/HttpService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function __construct(Factory $http = null)
{
$this->http = $http ?? new Factory();
}

/**
* @inheritDoc
*/
Expand Down
2 changes: 1 addition & 1 deletion src/StringHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static function xmlToElement(string $string): SimpleXMLElement
} catch (Throwable $throwable) {
libxml_use_internal_errors($internalErrors);

throw new RuntimeException( trans('larate::error.badxml', ['message' => $throwable->getMessage()]), $throwable->getCode(), $throwable );
throw new RuntimeException(trans('larate::error.badxml', ['message' => $throwable->getMessage()]), $throwable->getCode(), $throwable);
}

return $xml;
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/NationalBankOfUkraineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public function rcb_get_exchange_rate_response_throw_exception(): void
/** @test */
public function nbu_get_exchange_rate_response_failed(): void
{
$httpClient = Http::fake(fn($request) => Http::response([], 500));
$httpClient = Http::fake(fn ($request) => Http::response([], 500));

$rcb = new NationalBankOfUkraine($httpClient);
$pair = new CurrencyPair(self::BASE_CURRENCY, self::QUOTE_CURRENCY);
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/RussianCentralBankTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function rcb_get_exchange_rate_response_throw_exception(): void
*/
public function rcb_get_exchange_rate_response_failed(): void
{
$httpClient = Http::fake(fn($request) => Http::response([], 500));
$httpClient = Http::fake(fn ($request) => Http::response([], 500));

$rcb = new RussianCentralBank($httpClient);
$pair = new CurrencyPair(self::BASE_CURRENCY, self::QUOTE_CURRENCY);
Expand Down

0 comments on commit f754254

Please sign in to comment.