| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [View Raw Code] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
To implement a publish/subscribe behaviour to an object, whenever a "Subject" object changes its state, the attached "Observers" will be notified. It is used to shorten the amount of coupled objects and uses loose coupling instead.
PHP already defines two interfaces that can help to implement this pattern: SplObserver and SplSubject.
You can also find this code on GitHub
User.php
.. literalinclude:: User.php :language: php :linenos:
UserObserver.php
.. literalinclude:: UserObserver.php :language: php :linenos:
Tests/ObserverTest.php
.. literalinclude:: Tests/ObserverTest.php :language: php :linenos:
| Back | FazBrowse Home | New Git URL |