PSR-0 compliance

This commit is contained in:
Trismegiste
2013-08-24 00:20:07 +02:00
parent 7761fb74c1
commit 70299bc4c8
2 changed files with 32 additions and 23 deletions

26
Observer/UserObserver.php Normal file
View File

@@ -0,0 +1,26 @@
<?php
namespace DesignPatterns\Observer;
/**
* Observer pattern
*
* Purpose:
* to implement a publish/subscribe behaviour to an object, whenever a "Subject" object changes it's state, the attached
* "Observers" will be notified. It is used to shorten the amount of coupled objects and uses loose coupling instead
*
* Examples:
* - a message queue system is observed to show the progress of a job in a GUI
*
* PHP already defines two interfaces that can help to implement this pattern: SplObserver and SplSubject
*
*/
class UserObserver implements \SplObserver
{
public function update(\SplSubject $subject)
{
echo get_class($subject) . ' has been updated';
}
}