terpomoj/pipe

Pipe operator alternative.

Maintainers

Details

github.com/terpomoj/pipe

Source

Issues

Installs: 659

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/terpomoj/pipe

v0.1.0 2022-06-09 10:22 UTC

This package is auto-updated.

Last update: 2025-10-09 18:06:21 UTC


README

This is an alternatives to the declined PHP Pipe Operator RFC.

The idea was first introduced by Taylor Otwell on Twitter. I added some feature, such as directly call the function on the piping value, and directly accessing attribute of the piping value.

Usage Examples

Basic Usage

pipe('test@example.com')
    (md5(...))
    (fn ($md5) => 'https://gravatar.com/avatar/' . $md5)
    ->endpipe;

Accessing Object Attribute

pipe('test@example.com')
    (GravatarUrl::make(...))
    ->url // `url` is an attribute of GravatarUrl
    ->endpipe;

Calling Object Method

pipe('test@example.com')
    (GravatarUrl::make(...))
    ->size(200) // `size` is a method of GravatarUrl
    ->endpipe;

License

MIT License