MCPcopy Index your code
hub / github.com/php/frankenphp / buildContent

Method buildContent

internal/extgen/gofile.go:44–75  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42}
43
44func (gg *GoFileGenerator) buildContent() (string, error) {
45 sourceAnalyzer := SourceAnalyzer{}
46 packageName, variables, internalFunctions, err := sourceAnalyzer.analyze(gg.generator.SourceFile)
47 if err != nil {
48 return "", fmt.Errorf("analyzing source file: %w", err)
49 }
50
51 classes := make([]phpClass, len(gg.generator.Classes))
52 copy(classes, gg.generator.Classes)
53
54 templateContent, err := gg.getTemplateContent(goTemplateData{
55 PackageName: packageName,
56 BaseName: gg.generator.BaseName,
57 SanitizedBaseName: SanitizePackageName(gg.generator.BaseName),
58 Constants: gg.generator.Constants,
59 Variables: variables,
60 InternalFunctions: internalFunctions,
61 Functions: gg.generator.Functions,
62 Classes: classes,
63 })
64
65 if err != nil {
66 return "", fmt.Errorf("executing template: %w", err)
67 }
68
69 fc, err := format.Source([]byte(templateContent))
70 if err != nil {
71 return "", fmt.Errorf("formatting source: %w", err)
72 }
73
74 return string(fc), nil
75}
76
77func (gg *GoFileGenerator) getTemplateContent(data goTemplateData) (string, error) {
78 funcMap := sprig.FuncMap()

Calls 3

analyzeMethod · 0.95
getTemplateContentMethod · 0.95
SanitizePackageNameFunction · 0.85