GetInfoResult.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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-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. /**
  23. * Represents a single Technorati GetInfo query result object.
  24. *
  25. * @category Zend
  26. * @package Zend_Service
  27. * @subpackage Technorati
  28. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. */
  31. class Zend_Service_Technorati_GetInfoResult
  32. {
  33. /**
  34. * Technorati author
  35. *
  36. * @var Zend_Service_Technorati_Author
  37. * @access protected
  38. */
  39. protected $_author;
  40. /**
  41. * A list of weblogs claimed by this author
  42. *
  43. * @var array
  44. * @access protected
  45. */
  46. protected $_weblogs = array();
  47. /**
  48. * Constructs a new object object from DOM Document.
  49. *
  50. * @param DomDocument $dom the ReST fragment for this object
  51. */
  52. public function __construct(DomDocument $dom)
  53. {
  54. $xpath = new DOMXPath($dom);
  55. /**
  56. * @see Zend_Service_Technorati_Author
  57. */
  58. require_once 'Zend/Service/Technorati/Author.php';
  59. $result = $xpath->query('//result');
  60. if ($result->length == 1) {
  61. $this->_author = new Zend_Service_Technorati_Author($result->item(0));
  62. }
  63. /**
  64. * @see Zend_Service_Technorati_Weblog
  65. */
  66. require_once 'Zend/Service/Technorati/Weblog.php';
  67. $result = $xpath->query('//item/weblog');
  68. if ($result->length >= 1) {
  69. foreach ($result as $weblog) {
  70. $this->_weblogs[] = new Zend_Service_Technorati_Weblog($weblog);
  71. }
  72. }
  73. }
  74. /**
  75. * Returns the author associated with queried username.
  76. *
  77. * @return Zend_Service_Technorati_Author
  78. */
  79. public function getAuthor() {
  80. return $this->_author;
  81. }
  82. /**
  83. * Returns the collection of weblogs authored by queried username.
  84. *
  85. * @return array of Zend_Service_Technorati_Weblog
  86. */
  87. public function getWeblogs() {
  88. return $this->_weblogs;
  89. }
  90. }