-
Notifications
You must be signed in to change notification settings - Fork 441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Swap #307
Update Swap #307
Conversation
I wonder if we should rather have a static factory for ExchangeRateProvider instead of the current solution. @florianv your feedback is very welcome. |
Thanks @sagikazarmark for taking initiative on that! This looks ok to me, nothing to add 👍 |
Thanks for the feedback @florianv |
@@ -42,6 +44,9 @@ | |||
"florianv/swap": "Exchange rates library for PHP", | |||
"psr/cache-implementation": "Used for Currency caching" | |||
}, | |||
"conflict": { | |||
"florianv/swap": "<3.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really needed? It's impossible to install this package with florianv/swap<3.0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm indeed, it's an optional dependency after all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't noticed it's in require-dev
, so in fact it is possible to install it with lower Swap version, but as you said, it's optional dependency so there is no sense to restrict it.
*/ | ||
private $swap; | ||
|
||
/** | ||
* @param SwapInterface $swap | ||
* @param Swap|ExchangeRateProvider $exchange |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's SwapExchange
that uses Swap
, shouldn't we make ExchangerExchange
that uses ExchangeRateProvider
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we would basically duplicate Swap with an exchange like that. Swap is a convenience wrapper around ExchangeRateProvider. However this exchange does not work without Swap, so I am not sure if we should just use Swap or not. It's just new SwapExchange(new Swap(/**/))
after all.
} | ||
|
||
if ($exchange instanceof ExchangeRateProvider) { | ||
$exchange = new Swap($exchange); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, what about just not accepting ExchangeRateProvider
here, it seems easy to make Swap
instance out of it and doing that will reduce complexity.
$exchange = new Swap($exchange); | ||
} | ||
|
||
$this->swap = $exchange; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$exchange
-> $swap
?
Applied fixes from StyleCI
Closes #298