]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/jsonactivitycollection.php
Merge remote-tracking branch 'gnuio/master' into nightly
[quix0rs-gnu-social.git] / lib / jsonactivitycollection.php
1 <?php
2 if (!defined('GNUSOCIAL')) { exit(1); }
3
4 /*
5  * Collection primarily as the root of an Activity Streams doc but can be used as the value
6  * of extension properties in a variety of situations.
7  *
8  * A valid Collection object serialization MUST contain at least the url or items properties.
9  */
10 class JSONActivityCollection {
11
12     /* Non-negative integer specifying the total number of activities within the stream */
13     protected $totalItems;
14
15     /* An array containing a listing of Objects of any object type */
16     protected $items;
17
18     /* IRI referencing a JSON document containing the full listing of objects in the collection */
19     protected $url;
20
21     /**
22      * Constructor
23      *
24      * @param array  $items       array of activity items
25      * @param string $url         url of a doc list all the objs in the collection
26      * @param int    $totalItems  total number of items in the collection
27      */
28     function __construct(array $items=[], $url = null)
29     {
30         $this->items      = empty($items) ? array() : $items;
31         $this->totalItems = count($items);
32         $this->url        = $url;
33     }
34
35     /**
36      * Get the total number of items in the collection
37      *
38      * @return int total the total
39      */
40     public function getTotalItems()
41     {
42         $this->totalItems = count($items);
43         return $this->totalItems;
44     }
45 }