web/lib/Zend/Mobile/Push/Message/Abstract.php
changeset 808 6b6c2214f778
child 1230 68c69c656a2c
equal deleted inserted replaced
807:877f952ae2bd 808:6b6c2214f778
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_Mobile
       
    17  * @subpackage Zend_Mobile_Push
       
    18  * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id$
       
    21  */
       
    22 
       
    23 /** Zend_Mobile_Push_Message_Interface **/
       
    24 require_once 'Zend/Mobile/Push/Message/Interface.php';
       
    25 
       
    26 /** Zend_Mobile_Push_Message_Exception **/
       
    27 require_once 'Zend/Mobile/Push/Message/Exception.php';
       
    28 
       
    29 /**
       
    30  * Message Abstract
       
    31  *
       
    32  * @category   Zend
       
    33  * @package    Zend_Mobile
       
    34  * @subpackage Zend_Mobile_Push_Message
       
    35  * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
       
    36  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    37  * @version    $Id$
       
    38  */
       
    39 abstract class Zend_Mobile_Push_Message_Abstract implements Zend_Mobile_Push_Message_Interface
       
    40 {
       
    41     /**
       
    42      * Token
       
    43      *
       
    44      * @var string
       
    45      */
       
    46     protected $_token;
       
    47 
       
    48     /**
       
    49      * Id
       
    50      *
       
    51      * @var scalar
       
    52      */
       
    53     protected $_id;
       
    54 
       
    55     /**
       
    56      * Get Token
       
    57      *
       
    58      * @return string
       
    59      */
       
    60     public function getToken()
       
    61     {
       
    62         return $this->_token;
       
    63     }
       
    64 
       
    65     /**
       
    66      * Set Token
       
    67      *
       
    68      * @param  string $token
       
    69      * @return Zend_Mobile_Push_Message_Abstract
       
    70      */
       
    71     public function setToken($token)
       
    72     {
       
    73         if (!is_string($token)) {
       
    74             throw new Zend_Mobile_Push_Message_Exception('$token must be a string');
       
    75         }
       
    76         $this->_token = $token;
       
    77         return $this;
       
    78     }
       
    79 
       
    80     /**
       
    81      * Get Message ID
       
    82      * 
       
    83      * @return scalar
       
    84      */
       
    85     public function getId()
       
    86     {
       
    87         return $this->_id;
       
    88     }
       
    89 
       
    90     /**
       
    91      * Set Message ID
       
    92      *
       
    93      * @param scalar $id
       
    94      * @return Zend_Mobile_Push_Message_Abstract
       
    95      * @throws Exception
       
    96      */
       
    97     public function setId($id)
       
    98     {
       
    99         if (!is_scalar($id)) {
       
   100             throw new Zend_Mobile_Push_Message_Exception('$id must be a scalar');
       
   101         }
       
   102         $this->_id = $id;
       
   103         return $this;
       
   104     }
       
   105 
       
   106     /**
       
   107      * Set Options
       
   108      *
       
   109      * @param array $options
       
   110      * @return Zend_Mobile_Push_Message_Abstract
       
   111      * @throws Zend_Mobile_Push_Message_Exception
       
   112      */
       
   113     public function setOptions(array $options)
       
   114     {
       
   115         foreach ($options as $k => $v) {
       
   116             $method = 'set' . ucwords($k);
       
   117             if (!method_exists($this, $method)) {
       
   118                 throw new Zend_Mobile_Push_Message_Exception('The method "' . $method . "' does not exist.");
       
   119             }
       
   120             $this->$method($v);
       
   121         }
       
   122         return $this;
       
   123     }
       
   124 
       
   125 
       
   126     /**
       
   127      * Validate Message format
       
   128      *
       
   129      * @return boolean
       
   130      */
       
   131     public function validate()
       
   132     {
       
   133         return true;
       
   134     }
       
   135 }