Automattic\WooCommerce\Internal\Shipping\FlatRate

WeightPlaceholder::normalize │ private │ WC 1.0

Coerce an untrusted weight into a non-negative float.

Weights reach this class through filters, so they can be anything. Negative weights are clamped the same way wc_get_weight() clamps them.

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

Хуков нет.

Возвращает

float.

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

// private - только в коде основоного (родительского) класса
$result = $this->normalize( $weight ): float;
$weight(разное) (обязательный)
Weight to coerce.

Код WeightPlaceholder::normalize() WC 11.3.0

private function normalize( $weight ): float {
	return is_numeric( $weight ) ? max( 0.0, (float) $weight ) : 0.0;
}