Skip to content

Instantly share code, notes, and snippets.

@agoalofalife
Last active July 6, 2017 08:39
Show Gist options
  • Save agoalofalife/2e96a17a529cb648595fd4d029b16087 to your computer and use it in GitHub Desktop.
Save agoalofalife/2e96a17a529cb648595fd4d029b16087 to your computer and use it in GitHub Desktop.
<?php
use League\Pipeline\Pipeline;
interface Registrator{}
interface Notificator{}
class Order implements Registrator,Notificator
{
protected $order;
public function getOrder()
{
return $this->order;
}
public function __toString()
{
return 'this is object Order';
}
}
class RegistratorLog
{
public function register(Registrator $something)
{
echo 'registration log ' . $something . '<br>';
return $something;
}
}
class NotificationSms
{
public function notification(Notificator $something)
{
echo 'notification ' . $something . '<br>';
return $something;
}
}
class NotificationEmail
{
public function notification(Notificator $something)
{
echo 'notification ' . $something . '<br>';
return $something;
}
}
$process = (new Pipeline)
->pipe([new RegistratorLog, 'register'])
->pipe([new NotificationSms, 'notification'])
->pipe([new NotificationEmail, 'notification']);
$result = $process->process( new Order() );
// we will get the result :
// registration log this is object Order
// notification this is object Order
// notification this is object Order
dd($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment