Source for file Observer.class.php

Documentation is available at Observer.class.php

  1. <?php
  2. /**
  3.  * Gumbo Library Framework
  4.  *
  5.  * LICENSE
  6.  * This library is being released under the terms of the New BSD License.  A
  7.  * copy of the license is packaged with the software (LICENSE.txt).  If no
  8.  * copy is found, a copy of the license template can be found at:
  9.  * http://www.opensource.org/licenses/bsd-license.php
  10.  * 
  11.  * @category Gumbo
  12.  * @package Observer
  13.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  14.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  15.  * @author Michael Luster <mluster79@yahoo.com>
  16.  * @link http://sourceforge.net/projects/phpgumbo
  17.  * @version 0.0.1
  18.  */
  19.  
  20. /**
  21.  * Observer Pattern Interface, Observer
  22.  * 
  23.  * An Observer is simply an object that wants to receive constant updates
  24.  * to the changes of another object (Observerable).  The Observer constructor
  25.  * should register with the Observerable.  The Observer should also define
  26.  * a destructor method (__destruct) to remove itself from any Observerable
  27.  * objects it registered with.
  28.  *
  29.  * @category Gumbo
  30.  * @package Observer
  31.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  32.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  33.  * @author Michael Luster <mluster79@yahoo.com>
  34.  * @link http://sourceforge.net/projects/phpgumbo
  35.  * @desc Observer Pattern Interface, Observer
  36.  * @version 0.0.1
  37.  */
  38.  
  39.     
  40.     /**
  41.      * Receives updated information from an Observerable object
  42.      * 
  43.      * The Observerable will send changes to the Observer through this method.  The
  44.      * data is a key=>val array, containing important information about the
  45.      * Observerable.  Each Observer will be required to parse the array for the
  46.      * correct details.  For example, if an Observerable send out updates on it's
  47.      * current status ($data['status'] = value), the Observer should look for
  48.      * just the 'status' key.
  49.      * 
  50.      * <pre>
  51.      * foreach ($data as $key=>$val) {
  52.      *     if ($key == "status") {
  53.      *         // do something with the value
  54.      *     }
  55.      * }
  56.      * </pre>
  57.      * 
  58.      * The key=>value approach was used because a single Observer can be registered
  59.      * with multiple Observerable objects.
  60.      * 
  61.      * @param array $data key=>val array with important data for the Observer
  62.      */
  63.     public function update ($data);
  64.     
  65. }
  66.  
  67. ?>