Skip to content
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

Merged
merged 4 commits into from
Oct 21, 2016
Merged

Update Swap #307

merged 4 commits into from
Oct 21, 2016

Conversation

sagikazarmark
Copy link
Collaborator

Closes #298

@sagikazarmark sagikazarmark added this to the 3.0.0 stable milestone Oct 20, 2016
@sagikazarmark
Copy link
Collaborator Author

I wonder if we should rather have a static factory for ExchangeRateProvider instead of the current solution.

@florianv your feedback is very welcome.

@florianv
Copy link

Thanks @sagikazarmark for taking initiative on that!

This looks ok to me, nothing to add 👍

@sagikazarmark
Copy link
Collaborator Author

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"
Copy link
Contributor

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.

Copy link
Collaborator Author

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.

Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Collaborator Author

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);
Copy link
Contributor

@pamil pamil Oct 20, 2016

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;
Copy link
Contributor

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants