josephlavin/tap 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

josephlavin/tap

最新稳定版本:v1.0.0

Composer 安装命令:

composer require josephlavin/tap

包简介

Stand alone port of Laravel's tap method.

README 文档

README

Build Status

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

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-24