Last active
August 29, 2015 14:24
-
-
Save leocavalcante/b1d64f09eb9c416d7dc2 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 | |
namespace Notification; | |
class Notification | |
{ | |
public function __contruct($title = null, $subject = null, $message = null) | |
{ | |
$this->title = $title; | |
$this->subject = $subject; | |
$this->message = $message; | |
} | |
public function notify(Provider $provider) | |
{ | |
return $provider->notify($this); | |
} | |
} | |
interface Provider | |
{ | |
public function notify(Notification $notification); | |
} | |
class FacebookProvider implements Provider | |
{ | |
public function notify(Notification $notification) { // dummy } | |
} | |
class SmsProvider implements Provider | |
{ | |
public function notify(Notification $notification) { // dummy } | |
} | |
$notification = new Notification('title', 'subject', 'message'); | |
$notification->notify(new FacebookProvider('acess_token')); | |
$notification->notify(new SmsProvider('phone_number')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment