Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require __DIR__ . '/vendor/autoload.php';
- class Mailer
- {
- public function mail($recipient, $content)
- {
- echo 'mail sent';
- }
- }
- class UserManager
- {
- private $mailer;
- public function __construct(Mailer $mailer)
- {
- $this->mailer = $mailer;
- }
- public function register($email, $password)
- {
- $this->mailer->mail($email, 'Hello and welcome!');
- }
- }
- $container = new DI\Container();
- $userManager = $container->get('UserManager');
- $userManager->register('john@gmail.com', 'password');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement