*/ private static array $made = array(); /** * One instance per name. * * @template T of object * @param string $name Name. * @param callable(): T $factory Builder. * @return T */ private static function one( string $name, callable $factory ): object { if ( ! isset( self::$made[ $name ] ) ) { self::$made[ $name ] = $factory(); } return self::$made[ $name ]; } public static function reset(): void { self::$made = array(); } private static function db(): \wpdb { global $wpdb; return $wpdb; } public static function bookables(): BookableRepository { return self::one( __FUNCTION__, static fn() => new BookableRepository( self::db() ) ); } public static function staff(): StaffRepository { return self::one( __FUNCTION__, static fn() => new StaffRepository( self::db() ) ); } public static function resources(): ResourceRepository { return self::one( __FUNCTION__, static fn() => new ResourceRepository( self::db() ) ); } public static function locations(): LocationRepository { return self::one( __FUNCTION__, static fn() => new LocationRepository( self::db() ) ); } public static function links(): LinkRepository { return self::one( __FUNCTION__, static fn() => new LinkRepository( self::db() ) ); } public static function schedules(): ScheduleRepository { return self::one( __FUNCTION__, static fn() => new ScheduleRepository( self::db() ) ); } public static function sessions_repo(): SessionRepository { return self::one( __FUNCTION__, static fn() => new SessionRepository( self::db() ) ); } public static function bookings(): BookingRepository { return self::one( __FUNCTION__, static fn() => new BookingRepository( self::db() ) ); } public static function holds(): HoldRepository { return self::one( __FUNCTION__, static fn() => new HoldRepository( self::db() ) ); } public static function customers(): CustomerRepository { return self::one( __FUNCTION__, static fn() => new CustomerRepository( self::db() ) ); } public static function payments(): PaymentRepository { return self::one( __FUNCTION__, static fn() => new PaymentRepository( self::db() ) ); } public static function coupons(): CouponRepository { return self::one( __FUNCTION__, static fn() => new CouponRepository( self::db() ) ); } public static function calendars(): CalendarRepository { return self::one( __FUNCTION__, static fn() => new CalendarRepository( self::db() ) ); } public static function activity(): ActivityLog { return self::one( __FUNCTION__, static fn() => new ActivityLog( self::db() ) ); } public static function messages(): MessageLog { return self::one( __FUNCTION__, static fn() => new MessageLog( self::db() ) ); } public static function tokens(): TokenRepository { return self::one( __FUNCTION__, static fn() => new TokenRepository( self::db() ) ); } public static function catalog(): Catalog { return self::one( __FUNCTION__, static fn() => new Catalog() ); } public static function availability(): Availability { return self::one( __FUNCTION__, static fn() => new Availability() ); } public static function sessions(): Sessions { return self::one( __FUNCTION__, static fn() => new Sessions() ); } public static function checkout(): Checkout { return self::one( __FUNCTION__, static fn() => new Checkout() ); } public static function methods(): PaymentMethods { return self::one( __FUNCTION__, static fn() => new PaymentMethods() ); } public static function payment_service(): PaymentService { return self::one( __FUNCTION__, static fn() => new PaymentService() ); } public static function payment_flow(): PaymentFlow { return self::one( __FUNCTION__, static fn() => new PaymentFlow() ); } public static function refunds(): Refunds { return self::one( __FUNCTION__, static fn() => new Refunds() ); } public static function notifier(): Notifier { return self::one( __FUNCTION__, static fn() => new Notifier() ); } public static function calendar_sync(): CalendarSync { return self::one( __FUNCTION__, static fn() => new CalendarSync() ); } public static function portal(): Portal { return self::one( __FUNCTION__, static fn() => new Portal() ); } public static function privacy(): Privacy { return self::one( __FUNCTION__, static fn() => new Privacy() ); } public static function setup(): Setup { return self::one( __FUNCTION__, static fn() => new Setup() ); } }