/library/Zend/Gdata/Health/Query.php

https://bitbucket.org/khuongduybui/openfisma · PHP · 285 lines · 127 code · 20 blank · 138 comment · 28 complexity · f20b1f1fcadc00bc379779182025fc41 MD5 · raw file

  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_Gdata
  17. * @subpackage Health
  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. /**
  23. * @see Zend_Gdata_Query
  24. */
  25. // require_once('Zend/Gdata/Query.php');
  26. /**
  27. * Assists in constructing queries for Google Health
  28. *
  29. * @link http://code.google.com/apis/health
  30. *
  31. * @category Zend
  32. * @package Zend_Gdata
  33. * @subpackage Health
  34. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. */
  37. class Zend_Gdata_Health_Query extends Zend_Gdata_Query
  38. {
  39. /**
  40. * URI of a user's profile feed.
  41. */
  42. const HEALTH_PROFILE_FEED_URI =
  43. 'https://www.google.com/health/feeds/profile/default';
  44. /**
  45. * URI of register (notices) feed.
  46. */
  47. const HEALTH_REGISTER_FEED_URI =
  48. 'https://www.google.com/health/feeds/register/default';
  49. /**
  50. * Namespace for an item category
  51. */
  52. const ITEM_CATEGORY_NS = 'http://schemas.google.com/health/item';
  53. /**
  54. * The default URI for POST methods
  55. *
  56. * @var string
  57. */
  58. protected $_defaultFeedUri = self::HEALTH_PROFILE_FEED_URI;
  59. /**
  60. * Sets the digest parameter's value.
  61. *
  62. * @param string $value
  63. * @return Zend_Gdata_Health_Query Provides a fluent interface
  64. */
  65. public function setDigest($value)
  66. {
  67. if ($value !== null) {
  68. $this->_params['digest'] = $value;
  69. }
  70. return $this;
  71. }
  72. /**
  73. * Returns the digest parameter's value.
  74. *
  75. * @return string The value set for the digest parameter.
  76. */
  77. public function getDigest()
  78. {
  79. if (array_key_exists('digest', $this->_params)) {
  80. return $this->_params['digest'];
  81. } else {
  82. return null;
  83. }
  84. }
  85. /**
  86. * Setter for category queries.
  87. *
  88. * @param string $item A category to query.
  89. * @param string $name (optional) A specific item to search a category for.
  90. * An example would be 'Lipitor' if $item is set to 'medication'.
  91. * @return Zend_Gdata_Health_Query Provides a fluent interface
  92. */
  93. public function setCategory($item, $name = null)
  94. {
  95. $this->_category = $item .
  96. ($name ? '/' . urlencode('{' . self::ITEM_CATEGORY_NS . '}' . $name) : null);
  97. return $this;
  98. }
  99. /**
  100. * Returns the query object's category.
  101. *
  102. * @return string id
  103. */
  104. public function getCategory()
  105. {
  106. return $this->_category;
  107. }
  108. /**
  109. * Setter for the grouped parameter.
  110. *
  111. * @param string $value setting a count of results per group.
  112. * @return Zend_Gdata_Health_Query Provides a fluent interface
  113. */
  114. public function setGrouped($value)
  115. {
  116. if ($value !== null) {
  117. $this->_params['grouped'] = $value;
  118. }
  119. return $this;
  120. }
  121. /**
  122. * Returns the value set for the grouped parameter.
  123. *
  124. * @return string grouped parameter.
  125. */
  126. public function getGrouped()
  127. {
  128. if (array_key_exists('grouped', $this->_params)) {
  129. return $this->_params['grouped'];
  130. } else {
  131. return null;
  132. }
  133. }
  134. /**
  135. * Setter for the max-results-group parameter.
  136. *
  137. * @param int $value Specifies the maximum number of groups to be
  138. * retrieved. Must be an integer value greater than zero. This parameter
  139. * is only valid if grouped=true.
  140. * @return Zend_Gdata_Health_Query Provides a fluent interface
  141. */
  142. public function setMaxResultsGroup($value)
  143. {
  144. if ($value !== null) {
  145. if ($value <= 0 || $this->getGrouped() !== 'true') {
  146. // require_once 'Zend/Gdata/App/InvalidArgumentException.php';
  147. throw new Zend_Gdata_App_InvalidArgumentException(
  148. 'The max-results-group parameter must be set to a value
  149. greater than 0 and can only be used if grouped=true');
  150. } else {
  151. $this->_params['max-results-group'] = $value;
  152. }
  153. }
  154. return $this;
  155. }
  156. /**
  157. * Returns the value set for max-results-group.
  158. *
  159. * @return int Returns max-results-group parameter.
  160. */
  161. public function getMaxResultsGroup()
  162. {
  163. if (array_key_exists('max-results-group', $this->_params)) {
  164. return $this->_params['max-results-group'];
  165. } else {
  166. return null;
  167. }
  168. }
  169. /**
  170. * Setter for the max-results-group parameter.
  171. *
  172. * @param int $value Specifies the maximum number of records to be
  173. * retrieved from each group. The limits that you specify with this
  174. * parameter apply to all groups. Must be an integer value greater than
  175. * zero. This parameter is only valid if grouped=true.
  176. * @return Zend_Gdata_Health_Query Provides a fluent interface
  177. */
  178. public function setMaxResultsInGroup($value)
  179. {
  180. if ($value !== null) {
  181. if ($value <= 0 || $this->getGrouped() !== 'true') {
  182. throw new Zend_Gdata_App_InvalidArgumentException(
  183. 'The max-results-in-group parameter must be set to a value
  184. greater than 0 and can only be used if grouped=true');
  185. } else {
  186. $this->_params['max-results-in-group'] = $value;
  187. }
  188. }
  189. return $this;
  190. }
  191. /**
  192. * Returns the value set for max-results-in-group.
  193. *
  194. * @return int Returns max-results-in-group parameter.
  195. */
  196. public function getMaxResultsInGroup()
  197. {
  198. if (array_key_exists('max-results-in-group', $this->_params)) {
  199. return $this->_params['max-results-in-group'];
  200. } else {
  201. return null;
  202. }
  203. }
  204. /**
  205. * Setter for the start-index-group parameter.
  206. *
  207. * @param int $value Retrieves only items whose group ranking is at
  208. * least start-index-group. This should be set to a 1-based index of the
  209. * first group to be retrieved. The range is applied per category.
  210. * This parameter is only valid if grouped=true.
  211. * @return Zend_Gdata_Health_Query Provides a fluent interface
  212. */
  213. public function setStartIndexGroup($value)
  214. {
  215. if ($value !== null && $this->getGrouped() !== 'true') {
  216. throw new Zend_Gdata_App_InvalidArgumentException(
  217. 'The start-index-group can only be used if grouped=true');
  218. } else {
  219. $this->_params['start-index-group'] = $value;
  220. }
  221. return $this;
  222. }
  223. /**
  224. * Returns the value set for start-index-group.
  225. *
  226. * @return int Returns start-index-group parameter.
  227. */
  228. public function getStartIndexGroup()
  229. {
  230. if (array_key_exists('start-index-group', $this->_params)) {
  231. return $this->_params['start-index-group'];
  232. } else {
  233. return null;
  234. }
  235. }
  236. /**
  237. * Setter for the start-index-in-group parameter.
  238. *
  239. * @param int $value A 1-based index of the records to be retrieved from
  240. * each group. This parameter is only valid if grouped=true.
  241. * @return Zend_Gdata_Health_Query Provides a fluent interface
  242. */
  243. public function setStartIndexInGroup($value)
  244. {
  245. if ($value !== null && $this->getGrouped() !== 'true') {
  246. throw new Zend_Gdata_App_InvalidArgumentException('start-index-in-group');
  247. } else {
  248. $this->_params['start-index-in-group'] = $value;
  249. }
  250. return $this;
  251. }
  252. /**
  253. * Returns the value set for start-index-in-group.
  254. *
  255. * @return int Returns start-index-in-group parameter.
  256. */
  257. public function getStartIndexInGroup()
  258. {
  259. if (array_key_exists('start-index-in-group', $this->_params)) {
  260. return $this->_params['start-index-in-group'];
  261. } else {
  262. return null;
  263. }
  264. }
  265. }