function register(Lesson $lesson) { // do something with this Lesson // now tell someone $notifier = Notifier::getNotifier(); $notifier->inform("new lesson: cost ({$lesson->cost()})"); }
public function register(Lesson $lesson) { // marking registration // ... // notify $notifier = Notifier::getNotifier(); $notifier->inform("new lesson. cost = {$lesson->cost()}"); }
<?php declare (strict_types=1); namespace blog\factory; require 'autoload.php'; try { $data = array(1, 2, 3, 4, 5); $typeNotifications = array(Notifier::EMAIL, Notifier::SFTP, Notifier::EMAIL); foreach ($typeNotifications as $type) { $notifier = Notifier::getNotifier($type, $data); echo $notifier->notify() . PHP_EOL; } } catch (\Exception $e) { echo $e->getMessage() . PHP_EOL; }