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

Make \Cknow\Money\Money object from \Money\Money object #45

Closed
atymic opened this issue Feb 12, 2020 · 2 comments
Closed

Make \Cknow\Money\Money object from \Money\Money object #45

atymic opened this issue Feb 12, 2020 · 2 comments

Comments

@atymic
Copy link

atymic commented Feb 12, 2020

I plan to do a PR for #19, but it the mean time i'm using the conversion features from moneyPHP directly.

The issue is that they return a Money\Money object, which breaks the downstream type hints for \Cknow\Money\Money.

I propose to add a static constructor that returns an instance of this library's class from the base money object. That way, I can massage it back to the right type :)

\Cknow\Money\Money::fromMoney(\Money\Money $money): \Cknow\Money\Money

Will PR shortly if that's ok :)

@ricardogobbosouza
Copy link
Member

Hi @atymic
Sorry for the late answer

You can use the convert method
https://github.com/cknow/laravel-money/blob/master/src/Money.php#L117

@atymic
Copy link
Author

atymic commented Mar 6, 2020

Oops, don't know how I missed that!
Closing this :P

@atymic atymic closed this as completed Mar 6, 2020
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 a pull request may close this issue.

2 participants