-
Notifications
You must be signed in to change notification settings - Fork 0
Use assertions #4
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
base: master
Are you sure you want to change the base?
Conversation
|
This does place some additional restrictions on the typing... we'll no longer be able to:
I think having a |
src/Boolean.php
Outdated
| if ($value === null) { | ||
| throw new InvalidArgumentException('Value must be boolean'); | ||
| } | ||
| $assert = that($value)->boolean(); |
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.
$assert is never used
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.
Fixed.
Using `beberlei/assert` to simplify validation. This does not help with boolean type casting.
e661690 to
2c7934e
Compare
|
@equip/contributors all good? |
| if (!is_scalar($value)) { | ||
| throw new InvalidArgumentException('Value must a possible boolean'); | ||
| } | ||
| that($value)->nullOr()->scalar(); |
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.
personally I think it reads better as Assertion::that($value)->nullOr()->scalar();
"that" by itself seems to lack some context. If you want to keep the use maybe alias it?
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.
I don't agree, there is a clear use function at the top of the file.
Using
beberlei/assertto simplify validation.This does not help with boolean type casting.