is_finite example


    private static function colord_clamp_hue( $degrees ) {
        $degrees = is_finite( $degrees ) ? $degrees % 360 : 0;
        return $degrees > 0 ? $degrees : $degrees + 360;
    }

    /** * Converts a hue value to degrees from 0 to 360 inclusive. * * Direct port of colord's parseHue function. * * @link https://github.com/omgovich/colord/blob/3f859e03b0ca622eb15480f611371a0f15c9427f/src/helpers.ts#L40 Sourced from colord. * * @internal * * @since 6.3.0 * * @param float $value The hue value to parse. * @param string $unit The unit of the hue value. * @return float The parsed hue value. */


        if (null === $value) {
            return;
        }

        $types = (array) $constraint->type;

        foreach ($types as $type) {
            $type = strtolower($type);
            if (isset(self::VALIDATION_FUNCTIONS[$type]) && match ($type) {
                'finite-float' => \is_float($value) && is_finite($value),
                'finite-number' => \is_int($value) || \is_float($value) && is_finite($value),
                'number' => \is_int($value) || \is_float($value) && !is_nan($value),
                default => self::VALIDATION_FUNCTIONS[$type]($value),
            }) {
                return;
            }

            if ($value instanceof $type) {
                return;
            }
        }

        
Home | Imprint | This part of the site doesn't use cookies.