| Conditions | 3 |
| Paths | 3 |
| Total Lines | 28 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 28 | public function create(string $className): string |
||
| 29 | { |
||
| 30 | $schemaName = (new \ReflectionClass($className))->getShortName(); |
||
| 31 | |||
| 32 | $schema = $this->schemas->filter( |
||
| 33 | static function(Schema $schema) use ($schemaName): bool { |
||
| 34 | return $schema->schema === $schemaName; |
||
| 35 | } |
||
| 36 | )->first(); |
||
| 37 | |||
| 38 | $relatedSchemas = new Collection([$schema]); |
||
| 39 | |||
| 40 | foreach ($schema->properties as $property) { |
||
| 41 | if (UNDEFINED === $property->ref) { |
||
| 42 | continue; |
||
| 43 | } |
||
| 44 | |||
| 45 | $relatedSchemas = $relatedSchemas->append( |
||
| 46 | $this->schemas->filter( |
||
| 47 | static function(Schema $schema) use ($property): bool { |
||
| 48 | return $schema->schema === ucfirst($property->property); |
||
| 49 | } |
||
| 50 | ) |
||
| 51 | ); |
||
| 52 | } |
||
| 53 | |||
| 54 | return json_encode([ |
||
| 55 | 'schemas' => $relatedSchemas->toArray() |
||
| 56 | ]); |
||
| 59 |