Conditions | 4 |
Paths | 4 |
Total Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
14 | 3 | public function importFromFile(string $csvFile) |
|
15 | { |
||
16 | 3 | return $this->importFromString(file_get_contents($csvFile)); |
|
17 | } |
||
18 | |||
19 | 3 | public function importFromString(string $string) |
|
20 | { |
||
21 | 3 | $vcalendar = VObject\Reader::read($string); |
|
22 | |||
23 | 3 | $calendar = new CalendarModel(); |
|
24 | |||
25 | 3 | foreach ($vcalendar->VEVENT as $vevent) { |
|
26 | 3 | $event = new Event($vevent->DTSTART->getDateTime(), $vevent->DTEND->getDateTime()); |
|
27 | $event |
||
28 | 3 | ->setSummary($vevent->SUMMARY->getValue()) |
|
29 | 3 | ->setDescription($vevent->DESCRIPTION->getValue()) |
|
30 | ; |
||
31 | |||
32 | 3 | if (isset($vevent->RRULE)) { |
|
33 | 3 | $event->setRecurrenceRule(RecurrenceRule::createFromArray($vevent->RRULE->getParts())); |
|
34 | 2 | } elseif (isset($vevent->{'RECURRENCE-ID'})) { |
|
35 | 2 | $event->setRecurrenceId($vevent->{'RECURRENCE-ID'}->getDateTime()); |
|
36 | } |
||
37 | |||
38 | 3 | $calendar->addEvent($event); |
|
44 |