aweber_response.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * AWeberResponse
  4. *
  5. * Base class for objects that represent a response from the AWeberAPI.
  6. * Responses will exist as one of the two AWeberResponse subclasses:
  7. * - AWeberEntry - a single instance of an AWeber resource
  8. * - AWeberCollection - a collection of AWeber resources
  9. * @uses AWeberAPIBase
  10. * @package
  11. * @version $id$
  12. */
  13. class AWeberResponse extends AWeberAPIBase {
  14. public $adapter = false;
  15. public $data = array();
  16. public $_dynamicData = array();
  17. /**
  18. * __construct
  19. *
  20. * Creates a new AWeberRespones
  21. *
  22. * @param mixed $response Data returned by the API servers
  23. * @param mixed $url URL we hit to get the data
  24. * @param mixed $adapter OAuth adapter used for future interactions
  25. * @access public
  26. * @return void
  27. */
  28. public function __construct($response, $url, $adapter) {
  29. $this->adapter = $adapter;
  30. $this->url = $url;
  31. $this->data = $response;
  32. }
  33. /**
  34. * __set
  35. *
  36. * Manual re-implementation of __set, allows sub classes to access
  37. * the default behavior by using the parent:: format.
  38. *
  39. * @param mixed $key Key of the attr being set
  40. * @param mixed $value Value being set to the attr
  41. * @access public
  42. */
  43. public function __set($key, $value) {
  44. $this->{$key} = $value;
  45. }
  46. /**
  47. * __get
  48. *
  49. * PHP "MagicMethod" to allow for dynamic objects. Defers first to the
  50. * data in $this->data.
  51. *
  52. * @param String $value Name of the attribute requested
  53. * @access public
  54. * @return mixed
  55. */
  56. public function __get($value) {
  57. if (in_array($value, $this->_privateData)) {
  58. return null;
  59. }
  60. if (array_key_exists($value, $this->data)) {
  61. return $this->data[$value];
  62. }
  63. if ($value == 'type') return $this->_type();
  64. }
  65. }