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.

Метод класса: Mastercard{}

Хуков нет.

Возвращает

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

Использование

// private - только в коде основоного (родительского) класса
$result = $this->get_string_option( $payment_gateway, $key ): string;
$payment_gateway(WC_Payment_Gateway) (обязательный)
The payment gateway object.
$key(строка) (обязательный)
The option key to read.

Код Mastercard::get_string_option() WC 11.2.2

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 ) : '';
}