Skip to content

Instantly share code, notes, and snippets.

@ksmylmz
Created November 15, 2020 13:10
Show Gist options
  • Save ksmylmz/6337305ea34f88ed50eb8de3d17f0bd2 to your computer and use it in GitHub Desktop.
Save ksmylmz/6337305ea34f88ed50eb8de3d17f0bd2 to your computer and use it in GitHub Desktop.
<?php
////low Level sınıflarımız
class Email
{
function sendEmail();
}
class SMS
{
function sendSms();
}
class PushNotification
{
function sendPushNotification();
}
///High Level Sınıfımız
class MessageManager
{
$Email;
$SMS;
$PushNotification;
$type;
function __construct($type)
{
$this->type = $type;
}
public function sendMessage()
{
switch ($this->type)
{
case 'email':
$Email = new Email();
$Email->sendEmail();
break;
case 'SMS':
$SMS = new SMS();
$SMS->sendSms();
break;
case 'push':
$PushNotification = new PushNotification();
$PushNotification->sendPushNotification();
break;
default:
# code...
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment