Abstract.php 3.2 KB

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