File indexing completed on 2025-03-02 05:29:36

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Mobile
0017  * @subpackage Zend_Mobile_Push
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  */
0021 
0022 /** Zend_Mobile_Push_Message_Abstract **/
0023 // require_once 'Zend/Mobile/Push/Message/Abstract.php';
0024 
0025 /** Zend_Uri **/
0026 // require_once 'Zend/Uri.php';
0027 
0028 /**
0029  * Mpns Message
0030  *
0031  * @category   Zend
0032  * @package    Zend_Mobile
0033  * @subpackage Zend_Mobile_Push
0034  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0035  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0036  */
0037 abstract class Zend_Mobile_Push_Message_Mpns extends Zend_Mobile_Push_Message_Abstract
0038 {
0039     /**
0040      * Mpns types
0041      *
0042      * @var string
0043      */
0044     const TYPE_RAW = 'raw';
0045     const TYPE_TILE = 'token';
0046     const TYPE_TOAST = 'toast';
0047 
0048     /**
0049      * Delay
0050      *
0051      * @var int
0052      */
0053     protected $_delay;
0054 
0055     /**
0056      * Get Delay
0057      *
0058      * @return int
0059      */
0060     abstract public function getDelay();
0061 
0062     /**
0063      * Set Delay
0064      *
0065      * @param int $delay one of const DELAY_* of implementing classes
0066      * @return Zend_Mobile_Push_Message_Mpns
0067      */
0068     abstract public function setDelay($delay);
0069 
0070     /**
0071      * Get Notification Type
0072      *
0073      * @return string
0074      */
0075     public static function getNotificationType()
0076     {
0077         return "";
0078     }
0079 
0080     /**
0081      * Set Token
0082      *
0083      * @param string $token
0084      * @return Zend_Mobile_Push_Message_Mpns
0085      * @throws Zend_Mobile_Push_Message_Exception
0086      */
0087     public function setToken($token)
0088     {
0089         if (!is_string($token)) {
0090             throw new Zend_Mobile_Push_Message_Exception('$token is not a string');
0091         }
0092         if (!Zend_Uri::check($token)) {
0093             throw new Zend_Mobile_Push_Message_Exception('$token is not a valid URI');
0094         }
0095         return parent::setToken($token);
0096     }
0097 
0098     /**
0099      * Get XML Payload
0100      *
0101      * @return string
0102      */
0103     abstract public function getXmlPayload();
0104 
0105     /**
0106      * Validate proper mpns message
0107      *
0108      * @return boolean
0109      */
0110     public function validate()
0111     {
0112         if (!isset($this->_token) || strlen($this->_token) === 0) {
0113             return false;
0114         }
0115         return parent::validate();
0116     }
0117 }