This repository has been archived by the owner on Sep 27, 2019. It is now read-only.
Handle empty values a little more intelligently #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using an
empty
check or relying on a defaultarray_filter
, anything that is considered to be empty will be ignored.This means when using numeric values that can wind up being
0
, they will be interpreted as empty and stripped from the attribute.Unfortunately, this is then passed to HipChat as an invalid attribute (one without a value label), which returns a 400 error. Furthermore, HipChat's API error messages aren't the simplest to decipher.
The change I'm proposing will handle the empty case a little more intelligently, resulting in the expected (and valid) attribute array.
Using
trim($value) !== ''
takes into account other actually empty values (empty string,null
,false
, etc.), so other functionality is preserved.