Abstract.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. * @return MessageAbstract
  63. */
  64. public function setToken($token)
  65. {
  66. if (!is_string($token)) {
  67. throw new Zend_Mobile_Push_Message_Exception('$token must be a string');
  68. }
  69. $this->_token = $token;
  70. return $this;
  71. }
  72. /**
  73. * Get Message ID
  74. *
  75. * @return scalar
  76. */
  77. public function getId()
  78. {
  79. return $this->_id;
  80. }
  81. /**
  82. * Set Message ID
  83. *
  84. * @param scalar $id
  85. * @return MessageAbstract
  86. * @throws Exception
  87. */
  88. public function setId($id)
  89. {
  90. if (!is_scalar($id)) {
  91. throw new Zend_Mobile_Push_Message_Exception('$id must be a scalar');
  92. }
  93. $this->_id = $id;
  94. return $this;
  95. }
  96. /**
  97. * Set Options
  98. *
  99. * @param array $options
  100. * @return Zend_Mobile_Push_Message_Abstract
  101. * @throws Zend_Mobile_Push_Message_Exception
  102. */
  103. public function setOptions(array $options)
  104. {
  105. foreach ($options as $k => $v) {
  106. $method = 'set' . ucwords($k);
  107. if (!method_exists($this, $method)) {
  108. throw new Zend_Mobile_Push_Message_Exception('The method "' . $method . "' does not exist.");
  109. }
  110. $this->$method($v);
  111. }
  112. return $this;
  113. }
  114. /**
  115. * Validate Message format
  116. *
  117. * @return boolean
  118. */
  119. public function validate()
  120. {
  121. return true;
  122. }
  123. }