} The number of open * slots cleared, and the start datetime (`Y-m-d H:i:s`) of each booked * slot that still clashes with a session. */ public function reconcile( Offering $offering ): array { if ( Offering::KIND_GROUP_CLASS !== $offering->kind || $offering->instructorId <= 0 ) { return [ 'removed' => 0, 'conflicts' => [], ]; } $removed = 0; $conflicts = []; foreach ( $offering->sessionWindows() as $window ) { foreach ( $this->availability->findOverlapping( $offering->instructorId, $window['start'], $window['end'] ) as $slot ) { if ( $slot->isBooked ) { $conflicts[] = $slot->startDt; continue; } if ( null !== $slot->id && $this->availability->delete( $slot->id ) ) { ++$removed; } } } return [ 'removed' => $removed, 'conflicts' => $conflicts, ]; } }