bug: enhances example of Observer implementation, with actual change.

This commit is contained in:
luke-navitas
2021-11-29 17:06:09 +00:00
parent 152ec3dd34
commit b5d7e12b21

View File

@@ -15,6 +15,7 @@ use SplObserver;
class User implements SplSubject class User implements SplSubject
{ {
private SplObjectStorage $observers; private SplObjectStorage $observers;
private $email;
public function __construct() public function __construct()
{ {
@@ -33,6 +34,7 @@ class User implements SplSubject
public function changeEmail(string $email) public function changeEmail(string $email)
{ {
$this->email = $email;
$this->notify(); $this->notify();
} }