Lines
100.00%
9 / 9
Methods
100.00%
3 / 3
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| isBeyond | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 3 | ||
| hasReturned | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 3 | ||
| describeUsage | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 3 | ||
| 8 | enum ThresholdDirection | |
| 9 | { | |
| 10 | case Above; | |
| 11 | case Below; | |
| 12 | ||
| 13 | public function isBeyond(float $value, float $threshold): bool | |
| 14 | { | |
| 15 | return match ($this) { | |
| 16 | self::Above => $value > $threshold, | |
| 17 | self::Below => $value < $threshold, | |
| 18 | }; | |
| 19 | } | |
| 20 | ||
| 21 | public function hasReturned(float $value, float $threshold, float $hysteresis): bool | |
| 22 | { | |
| 23 | return match ($this) { | |
| 24 | self::Above => $value <= $threshold - $hysteresis, | |
| 25 | self::Below => $value >= $threshold + $hysteresis, | |
| 26 | }; | |
| 27 | } | |
| 28 | ||
| 29 | public function describeUsage(): string | |
| 30 | { | |
| 31 | return match ($this) { | |
| 32 | self::Above => 'whenAbove', | |
| 33 | self::Below => 'whenBelow', | |
| 34 | }; | |
| 35 | } | |
| 36 | } |