1: <?php // BUILD: Remove line
2:
3: namespace intouch\ical;
4:
5: /**
6: * A simple Factory for converting a section/data pair into the
7: * corrosponding block-object. If the section isn't known a simple
8: * ArrayObject is used instead.
9: *
10: * @author Morten Fangel (C) 2008
11: * @author Michael Kahn (C) 2013
12: * @license http://creativecommons.org/licenses/by-sa/2.5/dk/deed.en_GB CC-BY-SA-DK
13: */
14: class Factory {
15: /**
16: * Returns a new block-object for the section/data-pair. The list
17: * of returned objects is:
18: *
19: * vcalendar => intouch\ical\VCalendar
20: * vtimezone => intouch\ical\VTimeZone
21: * vevent => intouch\ical\VEvent
22: * * => ArrayObject
23: *
24: * @param $ical intouch\ical\iCal The reader this section/data-pair belongs to
25: * @param $section string
26: * @param intouch\ical\Line[]
27: */
28: public static function factory( iCal $ical, $section, $data ) {
29: switch( $section ) {
30: case "vcalendar":
31: return new VCalendar(Line::Remove_Line($data), $ical );
32: case "vtimezone":
33: return new VTimeZone(Line::Remove_Line($data), $ical );
34: case "vevent":
35: return new VEvent($data, $ical );
36:
37: default:
38: return new ArrayObject(Line::Remove_Line((array) $data) );
39: }
40: }
41: }
42: