src/Schema/Source/SchemaStitcher.php
protected static function gatherSchemaImportsRecursively(string $path): string
    {
        if (! file_exists($path)) {
            self::throwFileNotFoundException($path);
        }

        return (new Collection(file($path)))
            ->map(function (string $line) use ($path) {
                if (! Str::startsWith(trim($line), '#import ')) {
                    return rtrim($line, PHP_EOL).PHP_EOL;
                }

                $importFileName = trim(Str::after($line, '#import '));
                $importFilePath = dirname($path).'/'.$importFileName;

                if (! Str::contains($importFileName, '*')) {
                    $realPath = realpath($importFilePath);

                    if (! $realPath) {
                        self::throwFileNotFoundException($importFilePath);
                    }

                    return self::gatherSchemaImportsRecursively($realPath);
                }

                $importFilePaths = glob($importFilePath);

                return (new Collection($importFilePaths))
                    ->map(function ($file) {
                        return self::gatherSchemaImportsRecursively($file);
                    })
                    ->implode('');
            })
            ->implode('');
    }
protected static function gatherSchemaImportsRecursively(string $path): string
    {
        if (! file_exists($path)) {
            self::throwFileNotFoundException($path);
        }

        return (new Collection(file($path)))
            ->map(function (string $line) use ($path) {
                if (! Str::startsWith(trim($line), '#import ')) {
                    return rtrim($line, PHP_EOL).PHP_EOL;
                }

                $importFileName = trim(Str::after($line, '#import '));
                $importFilePath = dirname($path).'/'.$importFileName;

                if (! Str::contains($importFileName, '*')) {
                    $realPath = realpath($importFilePath);

                    if (! $realPath) {
                        self::throwFileNotFoundException($importFilePath);
                    }

                    return self::gatherSchemaImportsRecursively($realPath);
                }

                $importFilePaths = glob($importFilePath);

                return (new Collection($importFilePaths))
                    ->map(function ($file) {
                        return self::gatherSchemaImportsRecursively($file);
                    })
                    ->implode('');
            })
            ->implode('');
    }
protected static function gatherSchemaImportsRecursively ( string $ path ) : string { if ( ! file_exists ( $ path ) ) { self :: throwFileNotFoundException ( $ path ) ; } return ( new Collection ( file ( $ path ) ) ) -> map ( function ( string $ line ) use ( $ path ) { if ( ! Str :: startsWith ( trim ( $ line ) , '#import ' ) ) { return rtrim ( $ line , PHP_EOL ) . PHP_EOL ; } $ importFileName = trim ( Str :: after ( $ line , '#import ' ) ) ; $ importFilePath = dirname ( $ path ) . '/' . $ importFileName ; if ( ! Str :: contains ( $ importFileName , '*' ) ) { $ realPath = realpath ( $ importFilePath ) ; if ( ! $ realPath ) { self :: throwFileNotFoundException ( $ importFilePath ) ; } return self :: gatherSchemaImportsRecursively ( $ realPath ) ; } $ importFilePaths = glob ( $ importFilePath ) ; return ( new Collection ( $ importFilePaths ) ) -> map ( function ( $ file ) { return self :: gatherSchemaImportsRecursively ( $ file ) ; } ) -> implode ( '' ) ; } ) -> implode ( '' ) ; }
Get the schema, starting from a root schema, following the imports recursively.

@param  string  $path
@return string
Get the schema starting from a root schema following the imports recursively .