org-puremvc-php-multicore
[ class tree: org-puremvc-php-multicore ] [ index: org-puremvc-php-multicore ] [ all elements ]

Source for file Notification.php

Documentation is available at Notification.php

  1. <?php
  2. /**
  3.  * PureMVC Multicore Port to PHP
  4.  *
  5.  * Partly based on PureMVC Port to PHP by:
  6.  * - Omar Gonzalez <omar@almerblank.com>
  7.  * - and Hasan Otuome <hasan@almerblank.com>
  8.  *
  9.  * Created on Jully 24, 2009
  10.  *
  11.  * @version 1.0
  12.  * @author Michel Chouinard <michel.chouinard@gmail.com>
  13.  * @copyright PureMVC - Copyright(c) 2006-2008 Futurescale, Inc., Some rights reserved.
  14.  * @license http://creativecommons.org/licenses/by/3.0/ Creative Commons Attribution 3.0 Unported License
  15.  * @package org.puremvc.php.multicore
  16.  *
  17.  */
  18. /**
  19.  *
  20.  */
  21.  
  22. require_once 'org/puremvc/php/multicore/interfaces/INotification.php';
  23.  
  24. /**
  25.  * A base <b>INotification</b> implementation.
  26.  *
  27.  * PureMVC does not rely upon underlying event models such
  28.  * as the one provided with others like Flash, and PHP does
  29.  * not have an inherent event model.
  30.  *
  31.  * The Observer Pattern as implemented within PureMVC exists
  32.  * to support event-driven communication between the
  33.  * application and the actors of the MVC triad.
  34.  *
  35.  * PureMVC <b>Notification</b>s follow a 'Publish/Subscribe'
  36.  * pattern. PureMVC classes need not be related to each other in a
  37.  * parent/child relationship in order to communicate with one another
  38.  * using <b>Notification</b>s.
  39.  *
  40.  * @see Observer
  41.         org\puremvc\php\multicore\patterns\observer\Observer.php
  42.  * @package org.puremvc.php.multicore
  43.  *
  44.  */
  45. class Notification implements INotification
  46. {
  47.  
  48.     /**
  49.      * Name of the notification instance
  50.      * @var string 
  51.      */
  52.     private $name;
  53.  
  54.     /**
  55.      * The type of the notification instance
  56.      * @var string 
  57.      */
  58.     private $type;
  59.  
  60.     /**
  61.      * The body of the notification instance
  62.      * @var mixed 
  63.      */
  64.     private $body;
  65.  
  66.     /**
  67.      * Constructor.
  68.      *
  69.      * @param string $name The name of the notification to send.
  70.      * @param mixed $body The body of the notification (optional).
  71.      * @param string $type The type of the notification (optional).
  72.      */
  73.     public function __construct$name$body=null$type=null )
  74.     {
  75.         $this->name = $name;
  76.         $this->body = $body;
  77.         $this->type = $type;
  78.     }
  79.  
  80.     /**
  81.      * Name getter
  82.      *
  83.      * Get the name of the <b>Notification</b> instance.
  84.      *
  85.      * No setter, should be set by constructor only
  86.      *
  87.      * @return string Name of the <b>Notification</b> instance.
  88.      */
  89.     public function getName()
  90.     {
  91.         return $this->name;
  92.     }
  93.  
  94.     /**
  95.      * Body setter
  96.      *
  97.      * Set the body of the <b>Notification</b> instance.
  98.      *
  99.      * @param object $body The body of the <b>Notification</b> instance.
  100.      * @return void 
  101.      */
  102.     public function setBody$body )
  103.     {
  104.         $this->body = $body;
  105.     }
  106.  
  107.     /**
  108.      * Body getter
  109.      *
  110.      * Get the body of the <b>Notification</b> instance.
  111.      *
  112.      * @return mixed The body of the <b>Notification</b> instance.
  113.      */
  114.     public function getBody()
  115.     {
  116.         return $this->body;
  117.     }
  118.  
  119.     /**
  120.      * Type setter
  121.      *
  122.      * Set the type of the <b>Notification</b> instance.
  123.      *
  124.      * @param string $type The type of the <b>Notification</b> instance.
  125.      * @return void 
  126.      */
  127.     public function setType$type )
  128.     {
  129.         $this->type = $type;
  130.     }
  131.  
  132.     /**
  133.      * Type getter
  134.      *
  135.      * Get the type of the <b>Notification</b> instance.
  136.      *
  137.      * @return string The type of the <b>Notification</b> instance.
  138.      */
  139.     public function getType()
  140.     {
  141.         return $this->type;
  142.     }
  143.  
  144.     /**
  145.      * String representation
  146.      *
  147.      * Get the string representation of the <b>INotification</b> instance
  148.      *
  149.      * @return string 
  150.      */
  151.     public function toString()
  152.     {
  153.         $msg "Notification Name: "$this->getName();
  154.         $msg += "\nBody:".is_null$this->body "null" $this->body );
  155.         $msg += "\nType:".is_null$this->type "null" $this->type );
  156.         return $msg;
  157.     }
  158.  
  159. }

Documentation generated on Mon, 03 Aug 2009 04:58:00 +0000 by phpDocumentor 1.4.2