ics-parser icon indicating copy to clipboard operation
ics-parser copied to clipboard

How to know that parsed url is valid iCAL?

Open antonioperic opened this issue 4 years ago • 2 comments

Hi,

don't know where to ask, so I will try here.

I am using this line of code

$iCal = new ICal($message->getCalendarUrl());

and the result is always a valid object. Even if I send 'something' as calendarUrl

example of result

ICal\ICal {#3324
  +alarmCount: 0
  +eventCount: 0
  +freeBusyCount: 0
  +todoCount: 0
  +defaultSpan: 2
  +defaultTimeZone: "UTC"
  +defaultWeekStart: "MO"
  +skipRecurrence: false
  +disableCharacterReplacement: false
  +filterDaysBefore: null
  +filterDaysAfter: null
  +cal: []
  #freeBusyIndex: 0
  #lastKeyword: null
  #validIanaTimeZones: []
  #alteredRecurrenceInstances: []
  #weekdays: array:7 [
    "MO" => "monday"
    "TU" => "tuesday"
    "WE" => "wednesday"
    "TH" => "thursday"
    "FR" => "friday"
    "SA" => "saturday"
    "SU" => "sunday"
  ]
  #frequencyConversion: array:4 [
    "DAILY" => "day"
    "WEEKLY" => "week"
    "MONTHLY" => "month"
    "YEARLY" => "year"
  ]
  #httpBasicAuth: []
  #httpUserAgent: null
  #httpAcceptLanguage: null
  -windowMinTimestamp: -2147483648
  -windowMaxTimestamp: 9223372036854775807
  -shouldFilterByWindow: false
}

How I can know that parsed URL, or text is a valid calendar file?

thank you

antonioperic avatar Sep 30 '21 18:09 antonioperic

Great question - there currently isn't a mechanism for this functionality.

What would you expect? A new property called isValid which returns true or false?

u01jmg3 avatar Oct 04 '21 11:10 u01jmg3

Great question - there currently isn't a mechanism for this functionality.

What would you expect? A new property called isValid which returns true or false?

I just bumped into this problem today as well :) I was wondering why it was working with garbage input, I just assumed it would return NULL if no calendar was found.

nunodonato avatar Oct 26 '21 21:10 nunodonato

Please feel free to reopen if/when you'd like to submit a PR.

u01jmg3 avatar Mar 08 '24 16:03 u01jmg3