save()

in lib/generator.js [188:213]


  save(filepath) {
    let targetPath = filepath;
    if(path.resolve(filepath).startsWith(path.resolve(this.outputDir))) {
      const baseDir = path.join(this.outputDir, 'src', path.sep);
      filepath = filepath.replace(baseDir, '');
    }
    targetPath = path.join(this.outputDir, 'src', filepath);
    
    const namespace = this.getClassNamespace(filepath);
    const content = `<?php

// This file is auto-generated, don't edit it. Thanks.
 
namespace ${namespace};
${[...new Set(this.used)].join('\n')}
${this.output}`;

    fs.mkdirSync(path.dirname(targetPath), {
      recursive: true
    });
    fs.writeFileSync(targetPath, content);
    
    this.output = '';
    this.used = [];
    this.usedClass = new Map();
  }