Download the PHP package transprime-research/piper without Composer
On this page you can find all versions of the php package transprime-research/piper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download transprime-research/piper
More information about transprime-research/piper
Files in transprime-research/piper
Package piper
Short Description PHP Pipe method execution with values from chained method executions
License MIT
Homepage https://transprime-research.github.io/piper/
Informations about the package piper
piper
PHP Pipe function execution with values from initial call like F#
Pipe Like a PRO :ok:
Quick Usage
Let us take an array and do the following:
- flip the array to make the keys become the values and vice versa
- get the new keys
- change (the keys now) values to upper case
- take the exact item with
[0 => 'ADE']
Or this in PHP 8.1+
Getting ['H', 'E', 'L', 'L', 'O', ' ', 'W', 'O', 'R', 'L', 'D']
examples:
Use line - as in the line in Pipe-"line"
Think about ductape on a pipe. Ducter allows such neat calls to your functions
Call functions like an array:
How about Closure() on Closure
Cleaner with underscore _
Shortcut to pipe()
is p()
PHP 7.4 fn()
like
Proxied call to globally available functions
Instead of:
Or:
PS: You can still use the old
function() { return v; }
,fn()
is the new short arrow function in PHP 7.4+ See: https://www.php.net/manual/en/functions.arrow.php
Installation
composer require transprime-research/piper
Requirement
Minimum Requirement
- PHP 7.2 +
- Composer
Other Usages
piper()
function is a helper function. It is normally called like so:
Piper piper()
function accepts a callable instance on the second parameter that would be immediately on the first parameter:
Also accepts a class with an accessible method name. Say we have this class:
StrManipulator
class can be passed in with a method like so:
Even callable object is allowed like so:
Please see \Transprime\Piper\Tests\PiperTest
for more examples.
Coming Soon
- Backward Pipe with
fro()
looking like:
Api implementation to be decided
Additional Information
See other packages in this series here:
- https://github.com/omitobi/conditional [A smart PHP if...elseif...else statement]
- https://github.com/transprime-research/arrayed [A smarter Array now like an object]
- https://github.com/transprime-research/attempt [A smart PHP try...catch statement]
- https://github.com/omitobi/carbonate [A smart Carbon + Collection package]
- https://github.com/omitobi/laravel-habitue [Jsonable Http Request(er) package with Collections response]
Similar packages
Licence
MIT (See LICENCE file)