$terms_settings */ public static function from_settings( array $terms_settings ): self { $type = strtoupper( trim( (string) ( $terms_settings['contract_formation_mode'] ?? self::ORDER_CREATED ) ) ); if ( self::ORDER_STATUS === $type ) { return new self( $type, self::normalize_status( (string) ( $terms_settings['contract_formation_status'] ?? '' ) ) ); } if ( self::CUSTOM_PROVIDER === $type ) { return new self( $type, trim( (string) ( $terms_settings['contract_formation_provider'] ?? '' ) ) ); } return new self( $type ); } public static function is_supported_type( string $type ): bool { return in_array( strtoupper( trim( $type ) ), self::SUPPORTED, true ); } public static function normalize_status( string $status ): string { $status = strtolower( trim( $status ) ); return 0 === strpos( $status, 'wc-' ) ? substr( $status, 3 ) : $status; } public function matches( ContractFormationEvent $event ): bool { if ( $event->type() !== $this->type ) { return false; } if ( self::ORDER_STATUS === $this->type ) { return self::normalize_status( (string) $event->value() ) === self::normalize_status( (string) $this->value ); } if ( self::CUSTOM_PROVIDER === $this->type ) { return hash_equals( (string) $this->value, (string) $event->value() ); } return true; } public function get_type(): string { return $this->type; } public function get_value(): ?string { return $this->value; } /** @return array{type:string,value:?string} */ public function to_array(): array { return array( 'type' => $this->type, 'value' => $this->value, ); } }