mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-02 13:07:27 +02:00
Merge pull request #471 from luke-navitas/patch-1
Enhances example of Observer implementation, with actual change. Fixes #470
This commit is contained in:
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user