SHARE
TWEET

Untitled

a guest Apr 21st, 2017 4 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. class Student
  4. {
  5.     private $name;
  6.  
  7.     private $age;
  8.  
  9.     private $email;
  10.  
  11.     public function __construct($name, $age, $email)
  12.     {
  13.         $this->name = $name;
  14.         $this->age = $age;
  15.         $this->email = $email;
  16.     }
  17.  
  18.     public function getName()
  19.     {
  20.         return $this->name;
  21.     }
  22.  
  23.     public function getEmail()
  24.     {
  25.         return $this->email;
  26.     }
  27.  
  28.     public function getAge()
  29.     {
  30.         return $this->age;
  31.     }
  32. }
  33.  
  34. class StudentWelcomeEmailSender
  35. {
  36.     /**
  37.      * @var Student
  38.      */
  39.     private $student;
  40.  
  41.     /**
  42.      * @param Student $student
  43.      */
  44.     public function __construct(Student $student)
  45.     {
  46.         $this->student = $student;
  47.     }
  48.  
  49.     public function sendMessage()
  50.     {
  51.         $emailMessage = sprintf(
  52.             "Multumim pentru inscriere, %s. Contul tau a fost setat. " .
  53.             "In curand vei primi un email de notificare.",
  54.             $this->student->getName()
  55.         );
  56.  
  57.         return mail($this->student->getEmail(), 'Salut!', $emailMessage);
  58.     }
  59. }
  60.  
  61. $student = new Student('Gigi Kent 8', 20, 'gigi@kent.opt');
  62.  
  63. $welcomeMailSender = new StudentWelcomeEmailSender($student);
  64. $welcomeMailSender->sendMessage();
RAW Paste Data
Top