Skip to content

Conversation

@shadowhand
Copy link
Contributor

Using beberlei/assert to simplify validation.

This does not help with boolean type casting.

@shadowhand
Copy link
Contributor Author

This does place some additional restrictions on the typing... we'll no longer be able to:

  • pass string identifiers
  • pass empty strings generally

I think having a type_or_null() helper would be useful.

src/Boolean.php Outdated
if ($value === null) {
throw new InvalidArgumentException('Value must be boolean');
}
$assert = that($value)->boolean();
Copy link

Choose a reason for hiding this comment

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

$assert is never used

Copy link
Contributor Author

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.
@shadowhand
Copy link
Contributor Author

@equip/contributors all good?

@ameech
Copy link

ameech commented Aug 31, 2016

👍

Approved with PullApprove

if (!is_scalar($value)) {
throw new InvalidArgumentException('Value must a possible boolean');
}
that($value)->nullOr()->scalar();
Copy link

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?

Copy link
Contributor Author

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.

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.

5 participants