summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/inc/icalcoursebackend.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/locationinfo/inc/icalcoursebackend.inc.php')
-rw-r--r--modules-available/locationinfo/inc/icalcoursebackend.inc.php33
1 files changed, 15 insertions, 18 deletions
diff --git a/modules-available/locationinfo/inc/icalcoursebackend.inc.php b/modules-available/locationinfo/inc/icalcoursebackend.inc.php
index fba0866c..838d18b7 100644
--- a/modules-available/locationinfo/inc/icalcoursebackend.inc.php
+++ b/modules-available/locationinfo/inc/icalcoursebackend.inc.php
@@ -18,18 +18,9 @@ abstract class ICalCourseBackend extends CourseBackend
/** @var bool|resource */
private $curlHandle = false;
- /**
- * Initialize values
- *
- * @param string $location
- * @param bool $verifyCert
- * @param bool $verifyHostname
- * @param string $authMethod
- * @param string $user
- * @param string $pass
- */
- protected function init($location, $verifyCert, $verifyHostname,
- $authMethod = 'NONE', $user = '', $pass = '')
+ protected function init(
+ string $location, bool $verifyCert, bool $verifyHostname,
+ string $authMethod = 'NONE', string $user = '', string $pass = '')
{
$this->verifyCert = $verifyCert;
$this->verifyHostname = $verifyHostname;
@@ -43,19 +34,26 @@ abstract class ICalCourseBackend extends CourseBackend
}
/**
- * @param int $roomId room id
+ * @param string $roomId room id
* @param callable $errorFunc
* @return ICalEvent[]|null all events for this room in the range -7 days to +7 days, or NULL on error
*/
- protected function downloadIcal($roomId)
+ protected function downloadIcal(string $roomId): ?array
{
if (!$this->isOK())
return null;
+
+ try {
+ $ical = new ICalParser(['filterDaysBefore' => 7, 'filterDaysAfter' => 7]);
+ } catch (Exception $e) {
+ $this->addError('Error instantiating ICalParser: ' . $e->getMessage(), true);
+ return null;
+ }
+
if ($this->curlHandle === false) {
$this->curlHandle = curl_init();
}
- $ical = new ICalParser(['filterDaysBefore' => 7, 'filterDaysAfter' => 7]);
$options = [
CURLOPT_WRITEFUNCTION => function ($ch, $data) use ($ical) {
$ical->feedData($data);
@@ -92,7 +90,7 @@ abstract class ICalCourseBackend extends CourseBackend
return $ical->events();
}
- public function fetchSchedulesInternal($requestedRoomIds): array
+ public function fetchSchedulesInternal(array $requestedRoomIds): array
{
if (empty($requestedRoomIds) || !$this->isOK()) {
return array();
@@ -118,9 +116,8 @@ abstract class ICalCourseBackend extends CourseBackend
/**
* Get a usable title from either SUMMARY or DESCRIPTION
- * @param ICalEvent $event
*/
- private function toTitle($event): string
+ protected function toTitle(ICalEvent $event): string
{
$title = $event->summary;
if (empty($title)) {