Completed
Push — master ( 400ade...d957f6 )
by Daniel
27:07
created
apps/dav/lib/CalDAV/BirthdayService.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 				return;
77 77
 			}
78 78
 			foreach ($datesToSync as $type) {
79
-				$this->updateCalendar($cardUri, $cardData, $book, (int)$calendar['id'], $type, $reminderOffset);
79
+				$this->updateCalendar($cardUri, $cardData, $book, (int) $calendar['id'], $type, $reminderOffset);
80 80
 			}
81 81
 		}
82 82
 	}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
 			$calendar = $this->ensureCalendarExists($principalUri);
99 99
 			foreach (['', '-death', '-anniversary'] as $tag) {
100
-				$objectUri = $book['uri'] . '-' . $cardUri . $tag . '.ics';
100
+				$objectUri = $book['uri'].'-'.$cardUri.$tag.'.ics';
101 101
 				$this->calDavBackEnd->deleteCalendarObject($calendar['id'], $objectUri, CalDavBackend::CALENDAR_TYPE_CALENDAR, true);
102 102
 			}
103 103
 		}
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	public function buildDateFromContact(string $cardData,
132 132
 		string $dateField,
133 133
 		string $postfix,
134
-		?string $reminderOffset):?VCalendar {
134
+		?string $reminderOffset): ?VCalendar {
135 135
 		if (empty($cardData)) {
136 136
 			return null;
137 137
 		}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 			return null;
159 159
 		}
160 160
 		$birthday = $doc->{$dateField};
161
-		if (!(string)$birthday) {
161
+		if (!(string) $birthday) {
162 162
 			return null;
163 163
 		}
164 164
 		// Skip if the BDAY property is not of the right type.
@@ -177,21 +177,21 @@  discard block
 block discarded – undo
177 177
 			$omitYear = (isset($parameters['X-APPLE-OMIT-YEAR'])
178 178
 					&& $parameters['X-APPLE-OMIT-YEAR'] === $dateParts['year']);
179 179
 			// 'X-APPLE-OMIT-YEAR' is not always present, at least iOS 12.4 uses the hard coded date of 1604 (the start of the gregorian calendar) when the year is unknown
180
-			if ($omitYear || (int)$dateParts['year'] === 1604) {
180
+			if ($omitYear || (int) $dateParts['year'] === 1604) {
181 181
 				$dateParts['year'] = null;
182 182
 			}
183 183
 		}
184 184
 
185 185
 		$originalYear = null;
186 186
 		if ($dateParts['year'] !== null) {
187
-			$originalYear = (int)$dateParts['year'];
187
+			$originalYear = (int) $dateParts['year'];
188 188
 		}
189 189
 
190
-		$leapDay = ((int)$dateParts['month'] === 2 && (int)$dateParts['date'] === 29);
190
+		$leapDay = ((int) $dateParts['month'] === 2 && (int) $dateParts['date'] === 29);
191 191
 
192 192
 		if ($dateParts['year'] === null) {
193 193
 			$birthday = ($leapDay ? '1972-' : '1970-')
194
-				. $dateParts['month'] . '-' . $dateParts['date'];
194
+				. $dateParts['month'].'-'.$dateParts['date'];
195 195
 		}
196 196
 
197 197
 		try {
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		);
225 225
 
226 226
 		$vEvent->DTEND['VALUE'] = 'DATE';
227
-		$vEvent->{'UID'} = $doc->UID . $postfix;
227
+		$vEvent->{'UID'} = $doc->UID.$postfix;
228 228
 		$vEvent->{'RRULE'} = 'FREQ=YEARLY';
229 229
 		if ($leapDay) {
230 230
 			/* Sabre\VObject supports BYMONTHDAY only if BYMONTH
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		$vEvent->{'X-NEXTCLOUD-BC-FIELD-TYPE'} = $dateField;
237 237
 		$vEvent->{'X-NEXTCLOUD-BC-UNKNOWN-YEAR'} = $dateParts['year'] === null ? '1' : '0';
238 238
 		if ($originalYear !== null) {
239
-			$vEvent->{'X-NEXTCLOUD-BC-YEAR'} = (string)$originalYear;
239
+			$vEvent->{'X-NEXTCLOUD-BC-YEAR'} = (string) $originalYear;
240 240
 		}
241 241
 		if ($reminderOffset) {
242 242
 			$alarm = $vCal->createComponent('VALARM');
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 * @param string $user
254 254
 	 */
255 255
 	public function resetForUser(string $user):void {
256
-		$principal = 'principals/users/' . $user;
256
+		$principal = 'principals/users/'.$user;
257 257
 		$calendar = $this->calDavBackEnd->getCalendarByUri($principal, self::BIRTHDAY_CALENDAR_URI);
258 258
 		if (!$calendar) {
259 259
 			return; // The user's birthday calendar doesn't exist, no need to purge it
@@ -270,13 +270,13 @@  discard block
 block discarded – undo
270 270
 	 * @throws \Sabre\DAV\Exception\BadRequest
271 271
 	 */
272 272
 	public function syncUser(string $user):void {
273
-		$principal = 'principals/users/' . $user;
273
+		$principal = 'principals/users/'.$user;
274 274
 		$this->ensureCalendarExists($principal);
275 275
 		$books = $this->cardDavBackEnd->getAddressBooksForUser($principal);
276 276
 		foreach ($books as $book) {
277 277
 			$cards = $this->cardDavBackEnd->getCards($book['id']);
278 278
 			foreach ($cards as $card) {
279
-				$this->onCardChanged((int)$book['id'], $card['uri'], $card['carddata']);
279
+				$this->onCardChanged((int) $book['id'], $card['uri'], $card['carddata']);
280 280
 			}
281 281
 		}
282 282
 	}
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 		int $calendarId,
337 337
 		array $type,
338 338
 		?string $reminderOffset):void {
339
-		$objectUri = $book['uri'] . '-' . $cardUri . $type['postfix'] . '.ics';
339
+		$objectUri = $book['uri'].'-'.$cardUri.$type['postfix'].'.ics';
340 340
 		$calendarData = $this->buildDateFromContact($cardData, $type['field'], $type['postfix'], $reminderOffset);
341 341
 		$existing = $this->calDavBackEnd->getCalendarObject($calendarId, $objectUri);
342 342
 		if ($calendarData === null) {
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	 * @param string $userPrincipal
384 384
 	 * @return string|null
385 385
 	 */
386
-	private function principalToUserId(string $userPrincipal):?string {
386
+	private function principalToUserId(string $userPrincipal): ?string {
387 387
 		if (str_starts_with($userPrincipal, 'principals/users/')) {
388 388
 			return substr($userPrincipal, 17);
389 389
 		}
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 	 * @param string $userPrincipal
415 415
 	 * @return string|null
416 416
 	 */
417
-	private function getReminderOffsetForUser(string $userPrincipal):?string {
417
+	private function getReminderOffsetForUser(string $userPrincipal): ?string {
418 418
 		$userId = $this->principalToUserId($userPrincipal);
419 419
 		if ($userId !== null) {
420 420
 			return $this->config->getUserValue($userId, 'dav', 'birthdayCalendarReminderOffset', 'PT9H') ?: null;
@@ -443,20 +443,20 @@  discard block
 block discarded – undo
443 443
 					return implode('', [
444 444
 						'
Please login to merge, or discard this patch.