Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Math
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
4
100.00% covered (success)
100.00%
1 / 1
 isSubsetKey
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 clamp
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3declare(strict_types=1);
4
5namespace Projom\Util;
6
7class Math
8{
9    public static function isSubsetKey(array $subset, array $superset): bool
10    {
11        return count(array_diff_key($subset, $superset)) === 0;
12    }
13
14    public static function clamp(float|int $min, float|int $max, float|int $value): float|int
15    {
16        if ($value < $min)
17            return $min;
18        if ($value > $max)
19            return $max;
20        return $value;
21    }
22}