Conditions | 3 |
Paths | 4 |
Total Lines | 13 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
27 | protected function resolve(mixed $source, array $arguments, mixed $context, ResolveInfo $resolveInfo): mixed |
||
28 | { |
||
29 | /** @var UnitsData $source */ |
||
30 | $fieldName = $resolveInfo->fieldName; |
||
31 | // Special-case to `toString` since __ prefixes are reserved in GQL |
||
32 | if ($fieldName === 'toString') { |
||
33 | $fieldName = '__toString'; |
||
34 | } |
||
35 | // If the method exists, call it with the passed in args. Otherwise try to retur a property |
||
36 | if (method_exists($source, $fieldName)) { |
||
37 | return $source->$fieldName(...$arguments); |
||
38 | } else { |
||
39 | return $source->$fieldName; |
||
40 | } |
||
43 |