gettonline/pipeit

The missing pipe operator for PHP 7 and up

1.0.0 2021-07-28 23:02 UTC

This package is auto-updated.

Last update: 2024-09-11 20:26:58 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

The missing pipe operator for PHP 7 and up.

Installation

You can install the package via composer:

composer require gettonline/pipeit

Usage

Simple

pipe('foo bar')
    ->strtoupper()
    ->value

// FOO BAR

With value on a different position

Not all functions require the value as the first argument, with PIPE_IT you can move the value argument.

pipe('  hello there')
    ->trim()
    ->str_replace('there', 'world', PIPE_IT)
    ->ucwords()
    ->value

// Hello World

With a closures

pipe('gettonline.com')
    (function ($v) {
        return 'https://' . $v;
    })
    ->value

// https://gettonline.com

Automatically cast to string

print pipe([1,2,3])
    ->array_sum()

// 6

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.