property = $property; $this->field_key = $field_key; $this->value_parser = $value_parser; } protected function get_supported_properties(): array { return [ $this->property ]; } protected function convert_null( Conversion_Context $context, array $rule ): bool { $fields = $this->current_flex_fields( $context->get_prop( 'flex' ) ); $fields[ $this->field_key ] = null; $context->set_prop( 'flex', Flex_Prop_Type::generate( $fields ) ); return true; } protected function do_convert( Conversion_Context $context, array $rule ): bool { $parsed = ( $this->value_parser )( trim( $rule['value'] ) ); if ( null === $parsed ) { return false; } $fields = $this->current_flex_fields( $context->get_prop( 'flex' ) ); $fields[ $this->field_key ] = $parsed; $context->set_prop( 'flex', Flex_Prop_Type::generate( $fields ) ); return true; } private function current_flex_fields( $existing ): array { if ( is_array( $existing ) && Flex_Prop_Type::get_key() === ( $existing['$$type'] ?? null ) && is_array( $existing['value'] ?? null ) ) { return $existing['value']; } return []; } }