1: <?php
2:
3: namespace intouch\ical;
4:
5: use \IteratorAggregate;
6:
7: /**
8: * The wrapper for the main vcalendar data. Used instead of ArrayObject
9: * so you can easily query for title and description.
10: * Exposes a iterator that will loop though all the data
11: *
12: * @author Morten Fangel (C) 2008
13: * @author Michael Kahn (C) 2013
14: * @license http://creativecommons.org/licenses/by-sa/2.5/dk/deed.en_GB CC-BY-SA-DK
15: */
16: class VCalendar implements IteratorAggregate {
17: protected $data;
18:
19: /**
20: * Creates a new intouch\ical\VCalendar.
21: */
22: public function __construct($data) {
23: $this->data = $data;
24: }
25:
26: /**
27: * Returns the title of the calendar. If no title is known, NULL
28: * will be returned
29: * @return string
30: */
31: public function getTitle() {
32: if( isset($this->data['x-wr-calname']) ) {
33: return $this->data['x-wr-calname'];
34: } else {
35: return null;
36: }
37: }
38:
39: /**
40: * Returns the description of the calendar. If no description is
41: * known, NULL will be returned.
42: * @return string
43: */
44: public function getDescription() {
45: if( isset($this->data['x-wr-caldesc']) ) {
46: return $this->data['x-wr-caldesc'];
47: } else {
48: return null;
49: }
50: }
51:
52: /**
53: * @see IteratorAggregate.getIterator()
54: */
55: public function getIterator() {
56: return new ArrayIterator($this->data);
57: }
58: }
59:
60: