Automattic\WooCommerce\Internal\Admin\Settings

SettingsUISchema::is_canonical_number │ private static │ WC 1.0

Whether a value satisfies the final JavaScript number contract.

Method of the class: SettingsUISchema{}

No Hooks.

Returns

bool.

Usage

$result = SettingsUISchema::is_canonical_number( $value ): bool;
$value(mixed) (required)
Candidate value.

SettingsUISchema::is_canonical_number() code WC 11.2.1

private static function is_canonical_number( $value ): bool {
	if ( null === $value ) {
		return true;
	}

	if ( is_int( $value ) ) {
		/**
		 * Unsigned decimal representation.
		 *
		 * @var string $absolute
		 */
		$absolute = ltrim( (string) $value, '-' );
		return ! self::unsigned_decimal_is_greater( $absolute, self::JAVASCRIPT_SAFE_INTEGER );
	}

	if ( ! is_float( $value ) || ! is_finite( $value ) ) {
		return false;
	}

	/**
	 * Unsigned decimal representation.
	 *
	 * @var string $absolute
	 */
	$absolute = ltrim( sprintf( '%.0f', $value ), '-' );
	return floor( $value ) !== $value || ! self::unsigned_decimal_is_greater( $absolute, self::JAVASCRIPT_SAFE_INTEGER );
}