From 4c95226ff6939d1f721db476e6f91b95477bd850 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Sun, 15 Sep 2024 20:12:48 +0200 Subject: [PATCH] refactor: Refactor ternary to elvis operator where possible Signed-off-by: Christoph Wurst --- lib/CalDAV/Backend/PDO.php | 4 ++-- lib/CardDAV/Backend/PDO.php | 2 +- lib/DAV/Browser/Plugin.php | 2 +- lib/DAV/CorePlugin.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/CalDAV/Backend/PDO.php b/lib/CalDAV/Backend/PDO.php index 634b9828c5..91b5da4411 100644 --- a/lib/CalDAV/Backend/PDO.php +++ b/lib/CalDAV/Backend/PDO.php @@ -182,8 +182,8 @@ public function getCalendarsForUser($principalUri) 'id' => [(int) $row['calendarid'], (int) $row['id']], 'uri' => $row['uri'], 'principaluri' => $row['principaluri'], - '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'), - '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', + '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ?: '0'), + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0', '{'.CalDAV\Plugin::NS_CALDAV.'}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet($components), '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'), 'share-resource-uri' => '/ns/share/'.$row['calendarid'], diff --git a/lib/CardDAV/Backend/PDO.php b/lib/CardDAV/Backend/PDO.php index 7b935a4aec..e47545b7a5 100644 --- a/lib/CardDAV/Backend/PDO.php +++ b/lib/CardDAV/Backend/PDO.php @@ -73,7 +73,7 @@ public function getAddressBooksForUser($principalUri) '{DAV:}displayname' => $row['displayname'], '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], - '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0', ]; } diff --git a/lib/DAV/Browser/Plugin.php b/lib/DAV/Browser/Plugin.php index a8a6f430e4..e48011b58a 100644 --- a/lib/DAV/Browser/Plugin.php +++ b/lib/DAV/Browser/Plugin.php @@ -258,7 +258,7 @@ public function escapeHTML($value) */ public function generateDirectoryIndex($path) { - $html = $this->generateHeader($path ? $path : '/', $path); + $html = $this->generateHeader($path ?: '/', $path); $node = $this->server->tree->getNodeForPath($path); if ($node instanceof DAV\ICollection) { diff --git a/lib/DAV/CorePlugin.php b/lib/DAV/CorePlugin.php index dbd8976b17..ac9292801b 100644 --- a/lib/DAV/CorePlugin.php +++ b/lib/DAV/CorePlugin.php @@ -154,7 +154,7 @@ public function httpGet(RequestInterface $request, ResponseInterface $response) // Determining the exact byte offsets if (!is_null($range[0])) { $start = $range[0]; - $end = $range[1] ? $range[1] : $nodeSize - 1; + $end = $range[1] ?: $nodeSize - 1; if ($start >= $nodeSize) { throw new Exception\RequestedRangeNotSatisfiable('The start offset ('.$range[0].') exceeded the size of the entity ('.$nodeSize.')'); }