-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Labels
Description
Hi!
I suggest to add variadic variable to __invoke() method.
Example usages (DTO - Data Transfer Object):
$pipeline = (new Pipeline)
->pipe(function ($payload, DTO $dto) {
$dto['ten'] = 10;
return $payload * 2;
})
->pipe(function ($payload, DTO $dto) {
return $payload + $dto['key'];
});
$pipeline->process(5, new DTO);
//returns 20process method has ...$params
//https://github.com/thephpleague/pipeline/blob/master/src/Pipeline.php
/**
* Process the payload.
* @param $payload
* @return mixed
*/
public function process($payload, ...$params)
{
foreach ($this->stages as $stage) {
$payload = $stage($payload, ...$params);
}
return $payload;
}My example (old code, before update): https://github.com/Roquie/pipeline/commits/master
Note: PHP 5.6 required.
What do you think about it?
Isinlor, velosipedist, ingluisjimenez, ektarum, shadowhand and 3 morenyamsprod