| Total Complexity | 6 | 
| Total Lines | 61 | 
| Duplicated Lines | 0 % | 
| Coverage | 75% | 
| Changes | 0 | ||
| 1 | <?php | ||
| 11 | class Strength | ||
| 12 | { | ||
| 13 | /** | ||
| 14 | * @return float | ||
| 15 | */ | ||
| 16 | 21 | static public function required(): float | |
| 17 |     { | ||
| 18 | 21 | return self::create(1000.0, 1000.0, 1000.0); | |
| 19 | } | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @return float | ||
| 23 | */ | ||
| 24 | 1 | static public function strong(): float | |
| 25 |     { | ||
| 26 | 1 | return self::create(1.0, 0.0, 0.0); | |
| 27 | } | ||
| 28 | |||
| 29 | /** | ||
| 30 | * @return float | ||
| 31 | */ | ||
| 32 | static public function medium(): float | ||
| 33 |     { | ||
| 34 | return self::create(0.0, 1.0, 0.0); | ||
| 35 | } | ||
| 36 | |||
| 37 | /** | ||
| 38 | * @return float | ||
| 39 | */ | ||
| 40 | 3 | static public function weak(): float | |
| 43 | } | ||
| 44 | |||
| 45 | /** | ||
| 46 | * Create a new symbolic strength. | ||
| 47 | * | ||
| 48 | * @param float $a | ||
| 49 | * @param float $b | ||
| 50 | * @param float $c | ||
| 51 | * @param float $w | ||
| 52 | * @return float | ||
| 53 | */ | ||
| 54 | 21 | static public function create(float $a, float $b, float $c, float $w = 1.0): float | |
| 55 |     { | ||
| 56 | 21 | $strength = 0.0; | |
| 57 | 21 | $strength += max(0.0, min(1000.0, $a * $w)) * 1000000.0; | |
| 58 | 21 | $strength += max(0.0, min(1000.0, $b * $w)) * 1000.0; | |
| 59 | 21 | $strength += max(0.0, min(1000.0, $c * $w)); | |
| 60 | 21 | return $strength; | |
| 61 | } | ||
| 62 | |||
| 63 | /** | ||
| 64 | * Clamp a symbolic strength to the allowed min and max. | ||
| 65 | * | ||
| 66 | * @param float $strength | ||
| 67 | * @return float | ||
| 68 | */ | ||
| 69 | static public function clip(float $strength): float | ||
| 72 | } | ||
| 73 | } |