Aditya Purwa
1 min readApr 29, 2017

--

I never used this helper before, and I do not see why I should use this. Can someone explain why:

return tap($this->newModelInstance($attributes), function ($instance) { $instance->save(); });

is better than:

return $this->newModelInstance($attributes)->save();

Because if the reason is to return the value, which we definitely will use and definitely will also create variable for it, why not just use it normally?

$model = new Model($attr); $model->save();

In case if the class is not fluent, I do not see why we need to tap into it because in the end we will still store the tapped value into variables anyway.

--

--

Aditya Purwa

Building Playtune (https://playtune.app) - Software engineer, writer, designer, and artist.