@@ -52,8 +52,7 @@ public function __construct(
52
52
private readonly string $ dateFormat ,
53
53
private readonly string $ timezone ,
54
54
private readonly int $ cacheExpireSeconds ,
55
- )
56
- {
55
+ ) {
57
56
$ this ->mappings = $ this ->createMappings ($ this ->customMappings );
58
57
}
59
58
@@ -104,7 +103,7 @@ public function getData(Feed $feed): array
104
103
}, $ modifiedResults );
105
104
106
105
// Sort bookings by start time.
107
- usort ($ resultsAsArray , fn (array $ a , array $ b ) => $ a ['startTime ' ] > $ b ['startTime ' ] ? 1 : -1 );
106
+ usort ($ resultsAsArray , fn (array $ a , array $ b ) => $ a ['startTime ' ] > $ b ['startTime ' ] ? 1 : -1 );
108
107
109
108
return $ resultsAsArray ;
110
109
} catch (\Throwable $ throwable ) {
@@ -227,24 +226,24 @@ public function getConfigOptions(Request $request, FeedSource $feedSource, strin
227
226
$ resources = array_merge ($ resources , $ locationResources );
228
227
}
229
228
230
- $ resourceOptions = array_map (fn (Resource $ resource ) => [
229
+ $ resourceOptions = array_map (fn (Resource $ resource ) => [
231
230
'id ' => Ulid::generate (),
232
231
'title ' => $ resource ->displayName ,
233
232
'value ' => $ resource ->id ,
234
233
], $ resources );
235
234
236
235
// Sort resource options by title.
237
- usort ($ resourceOptions , fn ($ a , $ b ) => strcmp ((string )$ a ['title ' ], (string )$ b ['title ' ]));
236
+ usort ($ resourceOptions , fn ($ a , $ b ) => strcmp ((string ) $ a ['title ' ], (string ) $ b ['title ' ]));
238
237
239
238
return $ resourceOptions ;
240
239
} elseif ('locations ' === $ name ) {
241
- $ locationOptions = array_map (fn (Location $ location ) => [
240
+ $ locationOptions = array_map (fn (Location $ location ) => [
242
241
'id ' => Ulid::generate (),
243
242
'title ' => $ location ->displayName ,
244
243
'value ' => $ location ->id ,
245
244
], $ this ->loadLocations ());
246
245
247
- usort ($ locationOptions , fn ($ a , $ b ) => strcmp ((string )$ a ['title ' ], (string )$ b ['title ' ]));
246
+ usort ($ locationOptions , fn ($ a , $ b ) => strcmp ((string ) $ a ['title ' ], (string ) $ b ['title ' ]));
248
247
249
248
return $ locationOptions ;
250
249
}
@@ -292,12 +291,12 @@ private function getLocationOptions(): array
292
291
293
292
private function getResourceEvents (string $ resourceId ): array
294
293
{
295
- $ cacheItem = $ this ->calendarApiCache ->getItem (self ::CACHE_KEY_EVENTS . '- ' . $ resourceId );
294
+ $ cacheItem = $ this ->calendarApiCache ->getItem (self ::CACHE_KEY_EVENTS . '- ' . $ resourceId );
296
295
297
296
if (!$ cacheItem ->isHit ()) {
298
297
$ allEvents = $ this ->loadEvents ();
299
298
300
- $ items = array_filter ($ allEvents , fn (CalendarEvent $ item ) => $ item ->resourceId === $ resourceId );
299
+ $ items = array_filter ($ allEvents , fn (CalendarEvent $ item ) => $ item ->resourceId === $ resourceId );
301
300
302
301
$ cacheItem ->set ($ items );
303
302
$ cacheItem ->expiresAfter ($ this ->cacheExpireSeconds );
@@ -309,12 +308,12 @@ private function getResourceEvents(string $resourceId): array
309
308
310
309
private function getLocationResources (string $ locationId ): array
311
310
{
312
- $ cacheItem = $ this ->calendarApiCache ->getItem (self ::CACHE_KEY_RESOURCES . '- ' . $ locationId );
311
+ $ cacheItem = $ this ->calendarApiCache ->getItem (self ::CACHE_KEY_RESOURCES . '- ' . $ locationId );
313
312
314
313
if (!$ cacheItem ->isHit ()) {
315
314
$ allResources = $ this ->loadResources ();
316
315
317
- $ items = array_filter ($ allResources , fn (Resource $ item ) => $ item ->locationId === $ locationId );
316
+ $ items = array_filter ($ allResources , fn (Resource $ item ) => $ item ->locationId === $ locationId );
318
317
319
318
$ cacheItem ->set ($ items );
320
319
$ cacheItem ->expiresAfter ($ this ->cacheExpireSeconds );
@@ -334,7 +333,7 @@ private function loadLocations(): array
334
333
335
334
$ LocationEntries = $ response ->toArray ();
336
335
337
- $ locations = array_map (fn (array $ entry ) => new Location (
336
+ $ locations = array_map (fn (array $ entry ) => new Location (
338
337
$ entry [$ this ->getMapping ('locationId ' )],
339
338
$ entry [$ this ->getMapping ('locationDisplayName ' )],
340
339
), $ LocationEntries );
@@ -473,7 +472,7 @@ private function getMapping(string $key): string
473
472
474
473
private function shouldFetchNewData (string $ cacheKey ): bool
475
474
{
476
- $ latestRequestCacheItem = $ this ->calendarApiCache ->getItem ($ cacheKey . self ::CACHE_LATEST_REQUEST_SUFFIX );
475
+ $ latestRequestCacheItem = $ this ->calendarApiCache ->getItem ($ cacheKey. self ::CACHE_LATEST_REQUEST_SUFFIX );
477
476
$ latestRequest = $ latestRequestCacheItem ->get ();
478
477
479
478
return null === $ latestRequest || $ latestRequest <= time () - $ this ->cacheExpireSeconds ;
0 commit comments