Laravel's Illuminate\Support\Macroable trait allows you extend classes at runtime with custom methods. The idea is that you provide a named Closure, or callable value, which can then be invoked using PHP's __call() and __callStatic() magic methods.
The Collection object is known for it's fluency and method chaining and this bit of code doesn't fit into that pattern.
We can now call a magic path() method on the $collection and it will return the value found at the path provided. $baz = collect([ //... ]) ->path('foo.bar.baz'); Behind the scenes the method call is being delegated to the __call() method implemented by the Macroable trait.