HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: /home/xedaptot/iphim.naniguide.com/vendor/spatie/color/src/Contrast.php
<?php

namespace Spatie\Color;

class Contrast
{
    public static function ratio(Color $a, Color $b): float
    {
        if (! $a instanceof Hex) {
            $a = $a->toHex();
        }

        if (! $b instanceof Hex) {
            $b = $b->toHex();
        }

        $l1 =
            0.2126 * pow(hexdec($a->red()) / 255, 2.2) +
            0.7152 * pow(hexdec($a->green()) / 255, 2.2) +
            0.0722 * pow(hexdec($a->blue()) / 255, 2.2);

        $l2 =
            0.2126 * pow(hexdec($b->red()) / 255, 2.2) +
            0.7152 * pow(hexdec($b->green()) / 255, 2.2) +
            0.0722 * pow(hexdec($b->blue()) / 255, 2.2);

        if ($l1 > $l2) {
            return (int) (($l1 + 0.05) / ($l2 + 0.05));
        } else {
            return (int) (($l2 + 0.05) / ($l1 + 0.05));
        }
    }
}