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

[Product Variant] Price Calculator fixed to return always int #12549

Merged
merged 3 commits into from
Jan 17, 2022

Conversation

lruozzi9
Copy link
Contributor

Q A
Branch? 1.8
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets no
License MIT

This Pull Request will avoid returning null on int only return type allowed function. If getPrice is null for the channel the same exception is thrown.

@lruozzi9 lruozzi9 requested a review from a team as a code owner April 20, 2021 11:03
@vvasiloi
Copy link
Contributor

vvasiloi commented Jan 4, 2022

Hey @lruozzi9, thank you for your contribution!
Could you add some tests to cover these changes?

@lruozzi9
Copy link
Contributor Author

lruozzi9 commented Jan 4, 2022

Sure 👍🏻

@vvasiloi
Copy link
Contributor

vvasiloi commented Jan 4, 2022

@lruozzi9 Great! Thank you!
WDYT about changing the conditions to null !== X and returning early, then throw an exception at the end.
This will remove some unnecessary nesting...
Also, the logic to construct the error message is duplicated.
Maybe extract it to a factory method on the exception class, something like createForVariant?

@lruozzi9
Copy link
Contributor Author

lruozzi9 commented Jan 4, 2022

I agree, it is more readable! I will change it.

Copy link
Contributor

@vvasiloi vvasiloi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like you to make a few more changes if you don't mind.
I promise it's the last one from me.

@lruozzi9
Copy link
Contributor Author

Hey @vvasiloi! Sorry, I was a little busy these days! I will check your comments!

@lruozzi9
Copy link
Contributor Author

lruozzi9 commented Jan 12, 2022

I have a doubt about the location of the factory exception folder. Perhaps it is more correct to create a Factory folder inside Exception? Or an Exception folder inside Factory?

@vvasiloi
Copy link
Contributor

There's really no right or wrong here, it's all a matter of opinion, especially because there's no precedent for it in Sylius' codebase.
Let's have the factory in the same namespace as the exception class, that's what I saw others practice and it seems convenient.

@vvasiloi
Copy link
Contributor

On the other hand, we only have one case and I don't it changing anytime soon, so maybe it's better to just put the factory method inside the exception class.

@vvasiloi
Copy link
Contributor

@lruozzi9 I just noticed that you target branch 1.8 🤦‍♂️. Can you rebase your branch and change the target to 1.10?

@lruozzi9 lruozzi9 changed the base branch from 1.8 to 1.10 January 12, 2022 14:01
@lchrusciel lchrusciel added Bug Confirmed bugs or bugfixes. DX Issues and PRs aimed at improving Developer eXperience. labels Jan 14, 2022
@GSadee GSadee merged commit 75b9f8d into Sylius:1.10 Jan 17, 2022
@GSadee
Copy link
Member

GSadee commented Jan 17, 2022

Thanks, Lorenzo! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed bugs or bugfixes. DX Issues and PRs aimed at improving Developer eXperience.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants