[8.x] Add undot()
method to Arr helpers and Collections
#39729
Merged
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.
This PR adds support for
elevate
method in array helpers and collections.This method basically does the opposite of
Arr::dot()
, it takes an associative array and converts it to a multi-dimensional one based on keys with dot notation.For example if we take this array and pass it through
Arr::dot()
:We would get a flattened associative array:
Now if we elevate the dotted array we should get the original.
$elevated ≡ $original
Same goes for collections and lazy collections. Not sure if "elevate" is the best name for it, so I'm open to suggestions.
Cheers.
P.S. Will take a look on how to test if a collection is actually lazy and add an additional test. Some help is welcome, of course.