• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kornrunner / php-blurhash / 13845548032

13 Mar 2025 10:07PM UTC coverage: 100.0%. Remained the same
13845548032

push

github

web-flow
github: workflow: updates (#11)

136 of 136 relevant lines covered (100.0%)

4.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/AC.php
1
<?php
2

3
namespace kornrunner\Blurhash;
4

5
final class AC {
6

7
    public static function encode(array $value, float $max_value): float {
8
        $quant_r = static::quantise($value[0] / $max_value);
5✔
9
        $quant_g = static::quantise($value[1] / $max_value);
5✔
10
        $quant_b = static::quantise($value[2] / $max_value);
5✔
11
        return $quant_r * 19 * 19 + $quant_g * 19 + $quant_b;
5✔
12
    }
13

14
    public static function decode(int $value, float $max_value): array {
15
        $quant_r = intdiv($value, 19 * 19);
5✔
16
        $quant_g = intdiv($value, 19) % 19;
5✔
17
        $quant_b = $value % 19;
5✔
18

19
        return [
5✔
20
            static::signPow(($quant_r - 9) / 9, 2) * $max_value,
5✔
21
            static::signPow(($quant_g - 9) / 9, 2) * $max_value,
5✔
22
            static::signPow(($quant_b - 9) / 9, 2) * $max_value
5✔
23
        ];
5✔
24
    }
25

26
    private static function quantise(float $value): float {
27
        return floor(max(0, min(18, floor(static::signPow($value, 0.5) * 9 + 9.5))));
5✔
28
    }
29

30
    private static function signPow(float $base, float $exp): float {
31
        $sign = $base <=> 0;
10✔
32
        return $sign * pow(abs($base), $exp);
10✔
33
    }
34
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc