*/ private array $items = []; /** * Register. * * @param AutomationAction $action Action. * * @since 0.1.0 */ public function register( AutomationAction $action ): void { $this->items[ $action->identifier() ] = $action; } /** * Find. * * @param string $identifier Identifier. * * @since 0.1.0 */ public function get( string $identifier ): ?AutomationAction { return $this->items[ $identifier ] ?? null; } /** * All. * * @return list * * @since 0.1.0 */ public function all(): array { return array_values( $this->items ); } /** * Compatible with a subject type. * * @param SubjectType $subject Subject. * @return list * * @since 0.1.0 */ public function for_subject( SubjectType $subject ): array { $out = []; foreach ( $this->items as $action ) { if ( in_array( $subject, $action->subject_types(), true ) ) { $out[] = $action; } } return $out; } }