josephlavin/tap
最新稳定版本:v1.0.0
Composer 安装命令:
composer require josephlavin/tap
包简介
Stand alone port of Laravel's tap method.
README 文档
README
A stand alone port of Laravel's tap method (inspired by Ruby). This package will add a tap method to the global namespace. For more information see Taylor Otwell's explanation of tap.
Installation
composer require josephlavin/tap
Example
You need to create a model and commit it to the database using save:
function createAndSaveModel($attributes) { $model = new Model($attributes); $model->save(); return $model; }
The same code can be simplified utilizing tap:
function createAndSaveModel($attributes) { return tap(new Model($attributes), function (Model $model) { $model->save(); }); }
Utilizing the proxy feature it can be further simplified:
function createAndSaveModel($attributes) { return tap(new Model($attributes))->save(); }
统计信息
- 总下载量: 20.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-09-24