| Conditions | 5 |
| Paths | 7 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | private static function assertTimeFunction(?Closure $timeFunction): void |
||
| 33 | { |
||
| 34 | if (null === $timeFunction) { |
||
| 35 | return; |
||
| 36 | } |
||
| 37 | try { |
||
| 38 | $reflection = new ReflectionFunction($timeFunction); |
||
| 39 | if (1 !== $reflection->getNumberOfParameters()) { |
||
| 40 | throw new InvalidArgumentException('Time function must have no parameters'); |
||
| 41 | } |
||
| 42 | /** @psalm-suppress UndefinedMethod */ |
||
| 43 | if ('float' !== $reflection->getReturnType()?->getName()) { |
||
|
|
|||
| 44 | throw new InvalidArgumentException('Time function must return float'); |
||
| 45 | } |
||
| 46 | } catch (ReflectionException $e) { |
||
| 47 | throw new InvalidArgumentException('Time function has invalid signature: ' . $e->getMessage()); |
||
| 48 | } |
||
| 58 |