| Conditions | 6 |
| Paths | 9 |
| Total Lines | 24 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 6.4689 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 32 | 1 | public function getData(object $class, string $method): array |
|
| 33 | { |
||
| 34 | 1 | $reflection = new ReflectionMethod($class, $method); |
|
| 35 | 1 | if ($reflection->getNumberOfParameters() < 1) { |
|
| 36 | 1 | return []; |
|
| 37 | } |
||
| 38 | 1 | $dataProvider = $this->annotationsReader->getAnnotation(static::ANNOTATION_NAME, $class, $method); |
|
| 39 | 1 | if (is_string($dataProvider)) { |
|
| 40 | 1 | $className = $reflection->getDeclaringClass()->getName(); |
|
| 41 | try { |
||
| 42 | 1 | $reflection = new ReflectionMethod($class, $dataProvider); |
|
| 43 | 1 | if (!$reflection->isPublic()) { |
|
| 44 | throw new InvalidDataProviderException("Method $className::$dataProvider is not public."); |
||
| 45 | } |
||
| 46 | 1 | $result = call_user_func([$class, $dataProvider]); |
|
| 47 | 1 | if (!is_array($result)) { |
|
| 48 | throw new InvalidDataProviderException("Method $className::$dataProvider has to return an array."); |
||
| 49 | } |
||
| 50 | 1 | return $result; |
|
| 51 | } catch (\ReflectionException $e) { |
||
| 52 | throw new InvalidDataProviderException("Method $className::$dataProvider does not exist.", 0, $e); |
||
| 53 | } |
||
| 54 | } |
||
| 55 | 1 | return []; |
|
| 56 | } |
||
| 58 |