File indexing completed on 2024-05-26 06:03:14

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  * @version    $Id$
0021  */
0022 
0023 /** Zend_Mobile_Push_Interface **/
0024 // require_once 'Zend/Mobile/Push/Interface.php';
0025 
0026 /** Zend_Mobile_Push_Exception **/
0027 // require_once 'Zend/Mobile/Push/Exception.php';
0028 
0029 /**
0030  * Push Abstract
0031  *
0032  * @category   Zend
0033  * @package    Zend_Mobile
0034  * @subpackage Zend_Mobile_Push
0035  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0036  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0037  * @version    $Id$
0038  */
0039 abstract class Zend_Mobile_Push_Abstract implements Zend_Mobile_Push_Interface
0040 {
0041     /**
0042      * Is Connected
0043      *
0044      * @var boolean
0045      */
0046     protected $_isConnected = false;
0047 
0048     /**
0049      * Connect to the Push Server
0050      * 
0051      * @return Zend_Mobile_Push_Abstract
0052      */
0053     public function connect()
0054     {
0055         $this->_isConnected = true;
0056         return $this;
0057     }
0058 
0059     /**
0060      * Send a Push Message
0061      *
0062      * @param Zend_Mobile_Push_Message_Abstract $message
0063      * @return boolean
0064      * @throws DomainException
0065      */
0066     public function send(Zend_Mobile_Push_Message_Abstract $message)
0067     {
0068         if (!$this->_isConnected) {
0069             $this->connect();
0070         }
0071         return true;
0072     }
0073 
0074     /**
0075      * Close the Connection to the Push Server
0076      *
0077      * @return void
0078      */
0079     public function close()
0080     {
0081         $this->_isConnected = false;
0082     }
0083 
0084     /**
0085      * Is Connected
0086      *
0087      * @return boolean
0088      */
0089     public function isConnected()
0090     {
0091         return $this->_isConnected;
0092     }
0093 
0094     /**
0095      * Set Options
0096      *
0097      * @param array $options
0098      * @return Zend_Mobile_Push_Abstract
0099      * @throws Zend_Mobile_Push_Exception
0100      */
0101     public function setOptions(array $options)
0102     {
0103         foreach ($options as $k => $v) {
0104             $method = 'set' . ucwords($k);
0105             if (!method_exists($this, $method)) {
0106                 throw new Zend_Mobile_Push_Exception('The method "' . $method . "' does not exist.");
0107             }
0108             $this->$method($v);
0109         }
0110         return $this;
0111     }
0112 }