Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders

Mastercard::get_string_option │ private │ WC 1.0

Read a gateway option as a trimmed string.

Anything that is not a scalar — an array from a malformed settings entry, for example — is treated as absent rather than cast, since casting an array would both emit a warning and yield a non-empty string, which would read as a configured credential.

Method of the class: Mastercard{}

No Hooks.

Returns

string. The trimmed option value, or an empty string if it is absent or unusable.

Usage

// private - for code of main (parent) class only
$result = $this->get_string_option( $payment_gateway, $key ): string;
$payment_gateway(WC_Payment_Gateway) (required)
The payment gateway object.
$key(string) (required)
The option key to read.

Mastercard::get_string_option() code WC 11.3.0

private function get_string_option( WC_Payment_Gateway $payment_gateway, string $key ): string {
	$value = $payment_gateway->get_option( $key, '' );

	return is_scalar( $value ) ? trim( (string) $value ) : '';
}