Last active
July 6, 2017 08:39
-
-
Save agoalofalife/2e96a17a529cb648595fd4d029b16087 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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