Skip to content

Instantly share code, notes, and snippets.

@leocavalcante
Last active August 29, 2015 14:24
Show Gist options
  • Save leocavalcante/b1d64f09eb9c416d7dc2 to your computer and use it in GitHub Desktop.
Save leocavalcante/b1d64f09eb9c416d7dc2 to your computer and use it in GitHub Desktop.
<?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