| Conditions | 6 |
| Paths | 8 |
| Total Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 17 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | 8 | public function importFromString(string $string) |
|
| 20 | { |
||
| 21 | 8 | $vcalendar = VObject\Reader::read($string); |
|
| 22 | |||
| 23 | 8 | $calendar = new CalendarModel(); |
|
| 24 | |||
| 25 | 8 | if (!isset($vcalendar->VEVENT)) { |
|
| 26 | 1 | return $calendar; |
|
| 27 | } |
||
| 28 | |||
| 29 | 7 | foreach ($vcalendar->VEVENT as $vevent) { |
|
| 30 | 7 | $event = new Event($vevent->DTSTART->getDateTime(), $vevent->DTEND->getDateTime()); |
|
| 31 | $event |
||
| 32 | 7 | ->setSummary($vevent->SUMMARY->getValue()) |
|
| 33 | 7 | ->setDescription($vevent->DESCRIPTION->getValue()) |
|
| 34 | ; |
||
| 35 | |||
| 36 | 7 | if (isset($vevent->RRULE)) { |
|
| 37 | 5 | $event->setRecurrenceRule(RecurrenceRule::createFromArray($vevent->RRULE->getParts())); |
|
| 38 | 4 | } elseif (isset($vevent->{'RECURRENCE-ID'})) { |
|
| 39 | 2 | $event->setRecurrenceId($vevent->{'RECURRENCE-ID'}->getDateTime()); |
|
| 40 | } |
||
| 41 | |||
| 42 | 7 | if (isset($vevent->CLASS)) { |
|
| 43 | 2 | $event->setClassification($vevent->CLASS->getValue()); |
|
| 44 | } |
||
| 45 | |||
| 46 | 7 | $calendar->addEvent($event); |
|
| 47 | } |
||
| 48 | |||
| 49 | 7 | return $calendar; |
|
| 50 | } |
||
| 51 | } |
||
| 52 |