henzeb/laravel-pipeline-factory

v1.5.0 2024-03-11 10:45 UTC

This package is auto-updated.

Last update: 2024-10-11 11:58:25 UTC


README

Build Status Latest Version on Packagist Total Downloads Test Coverage License

Laravel has a convenient Pipeline to be used to separate the logic in a way that allows modifying an object and allows for easy interchangeable components.

Laravel Pipeline Factory takes it a step further and gives you a couple of 'pipes' to help you build a more complex pipeline.

Example

use Illuminate\Support\Facades\Pipeline;
use Henzeb\Pipeline\Facades\Pipe;
use App\Models\User;

$user = User::find(1);

Pipeline::send($user)
        ->through(
            Pipe::events(
                Pipe::unless(
                    UserEnteredPasswordTwice::class,
                    ReturnInvalidRequestResponse::class
                )->else(
                    Pipe::rescue(
                        Pipe::transaction(
                            [
                                UpdateUser::class,
                                UpdateAddress::class
                            ]
                        ),
                        ReturnFailureResponse::class,
                    )
                ),
                'updateUserDetails'
            )
        )

Installation

Just install with the following command.

composer require henzeb/laravel-pipeline-factory

usage

Every pipe included in this package is invokable. This means you don't have to stick with handle as it's via method.

The following pipes are available:

Testing this package

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email henzeberkheij@gmail.com instead of using the issue tracker.

Credits

License

The GNU AGPLv. Please see License File for more information.