Abstract.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. /** Zend_Mobile_Push_Message_Interface **/
  23. require_once 'Zend/Mobile/Push/Message/Interface.php';
  24. /** Zend_Mobile_Push_Message_Exception **/
  25. require_once 'Zend/Mobile/Push/Message/Exception.php';
  26. /**
  27. * Message Abstract
  28. *
  29. * @category Zend
  30. * @package Zend_Mobile
  31. * @subpackage Zend_Mobile_Push_Message
  32. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. * @version $Id$
  35. */
  36. abstract class Zend_Mobile_Push_Message_Abstract implements Zend_Mobile_Push_Message_Interface
  37. {
  38. /**
  39. * Token
  40. *
  41. * @var string
  42. */
  43. protected $_token;
  44. /**
  45. * Id
  46. *
  47. * @var scalar
  48. */
  49. protected $_id;
  50. /**
  51. * Get Token
  52. *
  53. * @return string
  54. */
  55. public function getToken()
  56. {
  57. return $this->_token;
  58. }
  59. /**
  60. * Set Token
  61. *
  62. * @param string $token
  63. * @return Zend_Mobile_Push_Message_Abstract
  64. */
  65. public function setToken($token)
  66. {
  67. if (!is_string($token)) {
  68. throw new Zend_Mobile_Push_Message_Exception('$token must be a string');
  69. }
  70. $this->_token = $token;
  71. return $this;
  72. }
  73. /**
  74. * Get Message ID
  75. *
  76. * @return scalar
  77. */
  78. public function getId()
  79. {
  80. return $this->_id;
  81. }
  82. /**
  83. * Set Message ID
  84. *
  85. * @param scalar $id
  86. * @return Zend_Mobile_Push_Message_Abstract
  87. * @throws Exception
  88. */
  89. public function setId($id)
  90. {
  91. if (!is_scalar($id)) {
  92. throw new Zend_Mobile_Push_Message_Exception('$id must be a scalar');
  93. }
  94. $this->_id = $id;
  95. return $this;
  96. }
  97. /**
  98. * Set Options
  99. *
  100. * @param array $options
  101. * @return Zend_Mobile_Push_Message_Abstract
  102. * @throws Zend_Mobile_Push_Message_Exception
  103. */
  104. public function setOptions(array $options)
  105. {
  106. foreach ($options as $k => $v) {
  107. $method = 'set' . ucwords($k);
  108. if (!method_exists($this, $method)) {
  109. throw new Zend_Mobile_Push_Message_Exception('The method "' . $method . "' does not exist.");
  110. }
  111. $this->$method($v);
  112. }
  113. return $this;
  114. }
  115. /**
  116. * Validate Message format
  117. *
  118. * @return boolean
  119. */
  120. public function validate()
  121. {
  122. return true;
  123. }
  124. }