KeyInfoResult.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 KeyInfo query result object.
  24. * It provides information about your Technorati API Key daily usage.
  25. *
  26. * @category Zend
  27. * @package Zend_Service
  28. * @subpackage Technorati
  29. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. */
  32. class Zend_Service_Technorati_KeyInfoResult
  33. {
  34. /**
  35. * Technorati API key
  36. *
  37. * @var string
  38. * @access protected
  39. */
  40. protected $_apiKey;
  41. /**
  42. * Number of queries used today
  43. *
  44. * @var int
  45. * @access protected
  46. */
  47. protected $_apiQueries;
  48. /**
  49. * Total number of available queries per day
  50. *
  51. * @var int
  52. * @access protected
  53. */
  54. protected $_maxQueries;
  55. /**
  56. * Constructs a new object from DOM Element.
  57. * Parses given Key element from $dom and sets API key string.
  58. *
  59. * @param DomElement $dom the ReST fragment for this object
  60. * @param string $apiKey the API Key string
  61. */
  62. public function __construct(DomDocument $dom, $apiKey = null)
  63. {
  64. // $this->_dom = $dom;
  65. // $this->_xpath = new DOMXPath($dom);
  66. $xpath = new DOMXPath($dom);
  67. $this->_apiQueries = (int) $xpath->query('/tapi/document/result/apiqueries/text()')->item(0)->data;
  68. $this->_maxQueries = (int) $xpath->query('/tapi/document/result/maxqueries/text()')->item(0)->data;
  69. $this->setApiKey($apiKey);
  70. }
  71. /**
  72. * Returns API Key string.
  73. *
  74. * @return string API Key string
  75. */
  76. public function getApiKey() {
  77. return $this->_apiKey;
  78. }
  79. /**
  80. * Returns the number of queries sent today.
  81. *
  82. * @return int number of queries sent today
  83. */
  84. public function getApiQueries() {
  85. return $this->_apiQueries;
  86. }
  87. /**
  88. * Returns Key's daily query limit.
  89. *
  90. * @return int maximum number of available queries per day
  91. */
  92. public function getMaxQueries() {
  93. return $this->_maxQueries;
  94. }
  95. /**
  96. * Sets API Key string.
  97. *
  98. * @param string $apiKey the API Key
  99. * @return Zend_Service_Technorati_KeyInfoResult $this instance
  100. */
  101. public function setApiKey($apiKey) {
  102. $this->_apiKey = $apiKey;
  103. return $this;
  104. }
  105. }