Last active
May 7, 2019 12:57
-
-
Save avosalmon/11d7c2a2d1796083407ebe8fa11c8a11 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 | |
interface OrderNotificationInterface | |
{ | |
public function notify(Order $order) : void; | |
} | |
class SlackNotification implements OrderNotificationInterface | |
{ | |
public function __construct(Slack $slack) { | |
$this->slack = $slack; | |
} | |
public function notify(Order $order) : void | |
{ | |
$message = $this->getMessage($order); | |
$this->slack->to('#order')->send($message); | |
} | |
protected function getMessage(Order $order) : string | |
{ | |
$format = '@%s Order has been processed. OrderID: %d'; | |
$userName = $order->getUserName(); | |
$message = sprintf($format, $userName, $order->getId()); | |
return $message; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment