-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSingleRP.php
57 lines (39 loc) · 1009 Bytes
/
SingleRP.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
# Wrong Way
Class Student{
public function feeCalculator(){}
public function gradeCalculator(){}
public function getAttandace(){}
}
#single Respon Prin
Class PaymentSystem{
}
Class GradeCalculator{
}
Class etAttanced{
}
// Single responsibity Example
Class Mailer{
function sendMail($to,$from,$sub,$message,$attachment){
}
function connectMTA($mtaType,$userName,$password){
}
function prepareMail($to,$form,$sub,$message){
}
function dispatch(){
}
}
//solid
Class BetterMail{
public function __construct(MailGateway $mg,MailInterface $mail,AttachmentInterface $attachment){
$this->mg = $mg;
$this->mail = $mail;
$this->atttachment = $attachment;
}
function sendMail($to,$from,$sub,$message,$attachment){
$this->mail->addAttachment($attachment);
$mailbody = $this->mail->prepare($to,$from,$sub,$message,$attachment);
$this->mg->connect();
$this->mg->send($mailbody);
}
}