1 : <?php
2 :
3 : /**
4 : * A representation of a page of resources.
5 : *
6 : * @category Services
7 : * @package Services_Twilio
8 : * @author Neuman Vong <neuman@twilio.com>
9 : * @license http://creativecommons.org/licenses/MIT/ MIT
10 : * @link http://pear.php.net/package/Services_Twilio
11 : */
12 : class Services_Twilio_Page
13 : implements IteratorAggregate
14 : {
15 :
16 : /**
17 : * The page object.
18 : *
19 : * @var object $page
20 : */
21 : protected $page;
22 :
23 : /**
24 : * The item list.
25 : *
26 : * @var array $items
27 : */
28 : protected $items;
29 :
30 : /**
31 : * Constructs a page.
32 : *
33 : * @param object $page The page object
34 : * @param string $name The key of the item list
35 : */
36 : public function __construct($page, $name)
37 : {
38 8 : $this->page = $page;
39 8 : $this->items = $page->{$name};
40 8 : }
41 :
42 : /**
43 : * The item list of the page.
44 : *
45 : * @return array A list of instance resources
46 : */
47 : public function getItems()
48 : {
49 6 : return $this->items;
50 : }
51 :
52 : /**
53 : * Magic method to allow retrieving the properties of the wrapped page.
54 : *
55 : * @param string $prop The property name
56 : *
57 : * @return mixed Could be anything
58 : */
59 : public function __get($prop)
60 : {
61 2 : return $this->page->$prop;
62 : }
63 :
64 : /**
65 : * Implementation of IteratorAggregate::getIterator().
66 : *
67 : * @return Traversable
68 : */
69 : public function getIterator()
70 : {
71 1 : return $this->getItems();
72 : }
73 : }
74 :
|