/zf/library/Zend/Service/Technorati/Author.php

http://github.com/eryx/php-framework-benchmark · PHP · 242 lines · 69 code · 32 blank · 141 comment · 12 complexity · babcb0d87706c727abf44c8ac2d5ff4a 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_Service
  17. * @subpackage Technorati
  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: Author.php 23775 2011-03-01 17:25:24Z ralph $
  21. */
  22. /**
  23. * @see Zend_Service_Technorati_Utils
  24. */
  25. require_once 'Zend/Service/Technorati/Utils.php';
  26. /**
  27. * Represents a weblog Author object. It usually belongs to a Technorati account.
  28. *
  29. * @category Zend
  30. * @package Zend_Service
  31. * @subpackage Technorati
  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. */
  35. class Zend_Service_Technorati_Author
  36. {
  37. /**
  38. * Author first name
  39. *
  40. * @var string
  41. * @access protected
  42. */
  43. protected $_firstName;
  44. /**
  45. * Author last name
  46. *
  47. * @var string
  48. * @access protected
  49. */
  50. protected $_lastName;
  51. /**
  52. * Technorati account username
  53. *
  54. * @var string
  55. * @access protected
  56. */
  57. protected $_username;
  58. /**
  59. * Technorati account description
  60. *
  61. * @var string
  62. * @access protected
  63. */
  64. protected $_description;
  65. /**
  66. * Technorati account biography
  67. *
  68. * @var string
  69. * @access protected
  70. */
  71. protected $_bio;
  72. /**
  73. * Technorati account thumbnail picture URL, if any
  74. *
  75. * @var null|Zend_Uri_Http
  76. * @access protected
  77. */
  78. protected $_thumbnailPicture;
  79. /**
  80. * Constructs a new object from DOM Element.
  81. *
  82. * @param DomElement $dom the ReST fragment for this object
  83. */
  84. public function __construct(DomElement $dom)
  85. {
  86. $xpath = new DOMXPath($dom->ownerDocument);
  87. $result = $xpath->query('./firstname/text()', $dom);
  88. if ($result->length == 1) $this->setFirstName($result->item(0)->data);
  89. $result = $xpath->query('./lastname/text()', $dom);
  90. if ($result->length == 1) $this->setLastName($result->item(0)->data);
  91. $result = $xpath->query('./username/text()', $dom);
  92. if ($result->length == 1) $this->setUsername($result->item(0)->data);
  93. $result = $xpath->query('./description/text()', $dom);
  94. if ($result->length == 1) $this->setDescription($result->item(0)->data);
  95. $result = $xpath->query('./bio/text()', $dom);
  96. if ($result->length == 1) $this->setBio($result->item(0)->data);
  97. $result = $xpath->query('./thumbnailpicture/text()', $dom);
  98. if ($result->length == 1) $this->setThumbnailPicture($result->item(0)->data);
  99. }
  100. /**
  101. * Returns Author first name.
  102. *
  103. * @return string Author first name
  104. */
  105. public function getFirstName() {
  106. return $this->_firstName;
  107. }
  108. /**
  109. * Returns Author last name.
  110. *
  111. * @return string Author last name
  112. */
  113. public function getLastName() {
  114. return $this->_lastName;
  115. }
  116. /**
  117. * Returns Technorati account username.
  118. *
  119. * @return string Technorati account username
  120. */
  121. public function getUsername() {
  122. return $this->_username;
  123. }
  124. /**
  125. * Returns Technorati account description.
  126. *
  127. * @return string Technorati account description
  128. */
  129. public function getDescription() {
  130. return $this->_description;
  131. }
  132. /**
  133. * Returns Technorati account biography.
  134. *
  135. * @return string Technorati account biography
  136. */
  137. public function getBio() {
  138. return $this->_bio;
  139. }
  140. /**
  141. * Returns Technorati account thumbnail picture.
  142. *
  143. * @return null|Zend_Uri_Http Technorati account thumbnail picture
  144. */
  145. public function getThumbnailPicture() {
  146. return $this->_thumbnailPicture;
  147. }
  148. /**
  149. * Sets author first name.
  150. *
  151. * @param string $input first Name input value
  152. * @return Zend_Service_Technorati_Author $this instance
  153. */
  154. public function setFirstName($input) {
  155. $this->_firstName = (string) $input;
  156. return $this;
  157. }
  158. /**
  159. * Sets author last name.
  160. *
  161. * @param string $input last Name input value
  162. * @return Zend_Service_Technorati_Author $this instance
  163. */
  164. public function setLastName($input) {
  165. $this->_lastName = (string) $input;
  166. return $this;
  167. }
  168. /**
  169. * Sets Technorati account username.
  170. *
  171. * @param string $input username input value
  172. * @return Zend_Service_Technorati_Author $this instance
  173. */
  174. public function setUsername($input) {
  175. $this->_username = (string) $input;
  176. return $this;
  177. }
  178. /**
  179. * Sets Technorati account biography.
  180. *
  181. * @param string $input biography input value
  182. * @return Zend_Service_Technorati_Author $this instance
  183. */
  184. public function setBio($input) {
  185. $this->_bio = (string) $input;
  186. return $this;
  187. }
  188. /**
  189. * Sets Technorati account description.
  190. *
  191. * @param string $input description input value
  192. * @return Zend_Service_Technorati_Author $this instance
  193. */
  194. public function setDescription($input) {
  195. $this->_description = (string) $input;
  196. return $this;
  197. }
  198. /**
  199. * Sets Technorati account thumbnail picture.
  200. *
  201. * @param string|Zend_Uri_Http $input thumbnail picture URI
  202. * @return Zend_Service_Technorati_Author $this instance
  203. * @throws Zend_Service_Technorati_Exception if $input is an invalid URI
  204. * (via Zend_Service_Technorati_Utils::normalizeUriHttp)
  205. */
  206. public function setThumbnailPicture($input) {
  207. $this->_thumbnailPicture = Zend_Service_Technorati_Utils::normalizeUriHttp($input);
  208. return $this;
  209. }
  210. }