Inspired by Laravel’s Illuminate\Support\Arr class, here is source code for new global helper functions data_dot() and data_has(). These compliment data_get() and data_set() already built into the framework.

This allows you to better handle nested state on array or Plain Old PHP Objects (POPO), with limited use on Eloquent models and Laravel Collection objects. They can also be re-purposed to support traversable types like SimpleXmlElement objects.

In an app/helpers.php file, add these function definitions:

data_dot()

data_has()

Then add this file’s path to your project’s composer.json 'autoload' prop:

composer dump-autoload from the command line and you can now perform conditional or filtering operations on object data. See the test assertions in the data_dot()/data_has() Gist for example use of these functions.