Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 0 0
  1. <?php
  2.  
  3. require __DIR__ . '/vendor/autoload.php';
  4.  
  5. class Mailer
  6. {
  7.     public function mail($recipient, $content)
  8.     {
  9.         echo 'mail sent';
  10.     }
  11. }
  12.  
  13. class UserManager
  14. {
  15.     private $mailer;
  16.  
  17.     public function __construct(Mailer $mailer)
  18.     {
  19.         $this->mailer = $mailer;
  20.     }
  21.  
  22.     public function register($email, $password)
  23.     {
  24.         $this->mailer->mail($email, 'Hello and welcome!');
  25.     }
  26. }
  27.  
  28. $container = new DI\Container();
  29. $userManager = $container->get('UserManager');
  30. $userManager->register('john@gmail.com', 'password');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement