*/ private array $providers = []; /** * Register a provider. * * @param BusyIntervalProvider $provider Provider. */ public function register( BusyIntervalProvider $provider ): void { $this->providers[ $provider->identifier() ] = $provider; } /** * Replace the set (after the busy_providers filter). * * @param list $providers Providers. */ public function replace( array $providers ): void { $this->providers = []; foreach ( $providers as $provider ) { if ( $provider instanceof BusyIntervalProvider ) { $this->register( $provider ); } } } /** * Registered providers. * * @return list */ public function all(): array { return array_values( $this->providers ); } /** * Union of every provider for this query. * * @param AvailabilityQuery $query Query. */ public function union( AvailabilityQuery $query ): IntervalSet { $set = IntervalSet::empty(); foreach ( $this->all() as $provider ) { $set = $set->union( $provider->get_busy_intervals( $query ) ); } return $set; } }