Hi!
I came across your library and I am gradually implementing it in the code base :)
I have a question, if somehow library covers this example?
if (!empty($someExternalArray['picture']['data']['url'])) {
$myArray['picture'] = $someExternalArray['picture']['data']['url'];
}
Is the setItem() designed for it? I'm not sure.
Maybe something like this would cover this need?
setConditionally($myArray, 'picture', $someExternalArray, 'picture.data.url'])
Of course, I know I can write myself such a helper, but it would be nice if library covered it as well.
The main key is not to clutter the $myArray with keys which we know will be empty, that's why I don't like this approach (and look for a simpler solution than the original if):
$myArray['picture'] = $someExternalArray['picture']['data']['url'] ?? null;
Hi!
I came across your library and I am gradually implementing it in the code base :)
I have a question, if somehow library covers this example?
Is the
setItem()designed for it? I'm not sure.Maybe something like this would cover this need?
setConditionally($myArray, 'picture', $someExternalArray, 'picture.data.url'])Of course, I know I can write myself such a helper, but it would be nice if library covered it as well.
The main key is not to clutter the
$myArraywith keys which we know will be empty, that's why I don't like this approach (and look for a simpler solution than the originalif):$myArray['picture'] = $someExternalArray['picture']['data']['url'] ?? null;