From 88e963a7c0c6c275181c37c47f9c6772b8ec5be3 Mon Sep 17 00:00:00 2001 From: dostrog Date: Sat, 20 Feb 2021 15:50:41 +0000 Subject: [PATCH] Fix styling --- .php_cs.cache | 2 +- src/Larate.php | 3 ++- src/Services/HttpService.php | 1 + src/StringHelper.php | 2 +- tests/Unit/NationalBankOfUkraineTest.php | 2 +- tests/Unit/RussianCentralBankTest.php | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.php_cs.cache b/.php_cs.cache index 68a9d96..682c5d1 100644 --- a/.php_cs.cache +++ b/.php_cs.cache @@ -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}} \ No newline at end of file +{"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}} \ No newline at end of file diff --git a/src/Larate.php b/src/Larate.php index 426045f..8bc4e99 100644 --- a/src/Larate.php +++ b/src/Larate.php @@ -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')); } } diff --git a/src/Services/HttpService.php b/src/Services/HttpService.php index 2a0f801..43f5470 100644 --- a/src/Services/HttpService.php +++ b/src/Services/HttpService.php @@ -21,6 +21,7 @@ public function __construct(Factory $http = null) { $this->http = $http ?? new Factory(); } + /** * @inheritDoc */ diff --git a/src/StringHelper.php b/src/StringHelper.php index d69ec4c..81a533c 100644 --- a/src/StringHelper.php +++ b/src/StringHelper.php @@ -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; diff --git a/tests/Unit/NationalBankOfUkraineTest.php b/tests/Unit/NationalBankOfUkraineTest.php index 9be0630..a1a70c1 100644 --- a/tests/Unit/NationalBankOfUkraineTest.php +++ b/tests/Unit/NationalBankOfUkraineTest.php @@ -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); diff --git a/tests/Unit/RussianCentralBankTest.php b/tests/Unit/RussianCentralBankTest.php index 8304975..31bd079 100644 --- a/tests/Unit/RussianCentralBankTest.php +++ b/tests/Unit/RussianCentralBankTest.php @@ -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);