*/ public static function all() { return array( Webhook::ID => Webhook::class, Telegram::ID => Telegram::class, Slack::ID => Slack::class, Discord::ID => Discord::class, Sheets::ID => Sheets::class, ); } /** * One service's class by id — null for a name the roster never held (a * queue row that survived from a build that knew more services than this * one is dropped by the drain, not guessed at). * * @param string $id Service id. * @return string|null */ public static function get( $id ) { $all = self::all(); return isset( $all[ (string) $id ] ) ? $all[ (string) $id ] : null; } /** * Whether ANY service is connected — the pipeline's arming condition. * * @param Settings $settings Plugin settings. * @return bool */ public static function any_connected( Settings $settings ) { foreach ( self::all() as $class ) { if ( $class::connected( $settings ) ) { return true; } } return false; } /** * The ids of every connected service that subscribed to an event AND * accepts this particular payload — who an emit fans out to. * * @param Settings $settings Plugin settings. * @param string $event Event name. * @param array $data The event's contract-shaped payload. * @return string[] */ public static function wanting( Settings $settings, $event, array $data ) { $ids = array(); foreach ( self::all() as $id => $class ) { if ( $class::wants( $settings, $event ) && $class::accepts( $settings, $event, $data ) ) { $ids[] = $id; } } return $ids; } }