2017 © Pedro Peláez
 

library tap

Stand alone port of Laravel's tap method.

image

josephlavin/tap

Stand alone port of Laravel's tap method.

  • Monday, September 25, 2017
  • by josephlavin
  • Repository
  • 1 Watchers
  • 0 Stars
  • 24 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 20 % Grown

The README.md

josephlavin/tap

Build Status, (*1)

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., (*2)

Installation

composer require josephlavin/tap

Example

You need to create a model and commit it to the database using save:, (*3)

function createAndSaveModel($attributes)
{
    $model = new Model($attributes);

    $model->save();

    return $model;
}

The same code can be simplified utilizing tap:, (*4)

function createAndSaveModel($attributes)
{
    return tap(new Model($attributes), function (Model $model) {
        $model->save();
    });
}

Utilizing the proxy feature it can be further simplified:, (*5)

function createAndSaveModel($attributes)
{
    return tap(new Model($attributes))->save();
}

The Versions

25/09 2017

dev-master

9999999-dev

Stand alone port of Laravel's tap method.

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

laravel php tap

25/09 2017

v1.0.0

1.0.0.0

Stand alone port of Laravel's tap method.

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

laravel php tap