| Conditions | 7 |
| Paths | 5 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types = 1); |
||
| 43 | private function findTypeInSchema(\stdClass $schema): string |
||
| 44 | { |
||
| 45 | if (isset($schema->{'x-type'})) { |
||
| 46 | return $schema->{'x-type'}; |
||
| 47 | } |
||
| 48 | if (!isset($schema->type)) { |
||
| 49 | return ''; |
||
| 50 | } |
||
| 51 | |||
| 52 | $getTypeFromReference = function ($schema) { |
||
| 53 | return $schema->{'x-type'} = substr($schema->{'x-ref-id'}, strrpos($schema->{'x-ref-id'}, '/') + 1); |
||
| 54 | }; |
||
| 55 | |||
| 56 | if ($schema->type === 'array' && $schema->items->type == 'object') { |
||
| 57 | return "{$getTypeFromReference($schema->items)}[]"; |
||
| 58 | } |
||
| 59 | if (isset($schema->{'x-ref-id'}) && $schema->type === 'object') { |
||
| 60 | return $getTypeFromReference($schema); |
||
| 61 | } |
||
| 62 | |||
| 63 | return ''; |
||
| 64 | } |
||
| 65 | } |
||
| 66 |