jsonactivitycollection.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /*
  3. * Collection primarily as the root of an Activity Streams doc but can be used as the value
  4. * of extension properties in a variety of situations.
  5. *
  6. * A valid Collection object serialization MUST contain at least the url or items properties.
  7. */
  8. class JSONActivityCollection {
  9. /* Non-negative integer specifying the total number of activities within the stream */
  10. protected $totalItems;
  11. /* An array containing a listing of Objects of any object type */
  12. protected $items;
  13. /* IRI referencing a JSON document containing the full listing of objects in the collection */
  14. protected $url;
  15. /**
  16. * Constructor
  17. *
  18. * @param array $items array of activity items
  19. * @param string $url url of a doc list all the objs in the collection
  20. * @param int $totalItems total number of items in the collection
  21. */
  22. function __construct($items = null, $url = null)
  23. {
  24. $this->items = empty($items) ? array() : $items;
  25. $this->totalItems = count($items);
  26. $this->url = $url;
  27. }
  28. /**
  29. * Get the total number of items in the collection
  30. *
  31. * @return int total the total
  32. */
  33. public function getTotalItems()
  34. {
  35. $this->totalItems = count($items);
  36. return $this->totalItems;
  37. }
  38. }