Conditions | 3 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | private static function assert(Closure $measureFunction): void |
||
22 | { |
||
23 | $reflection = new ReflectionFunction($measureFunction); |
||
24 | $returnType = $reflection->getReturnType()?->getName(); |
||
|
|||
25 | $parameterType = $reflection->getParameters()[0]->getType()?->getName(); |
||
26 | |||
27 | if ($parameterType === 'string' && $returnType === 'int') { |
||
28 | return; |
||
29 | } |
||
30 | |||
31 | throw new InvalidArgumentException( |
||
32 | 'Invalid measure function signature.' |
||
33 | . ' Signature expected to be: "function(string $string): int { //... }".' |
||
34 | ); |
||
42 |