from Outils.Directory import GenerateDirectory
from pathlib import Path

def createFileService(nom, specifique = ''):

    generateDirectory = GenerateDirectory(nom, "/Modules/"+nom+"/Service", specifique)
    directory = generateDirectory.getDirectory()
    namespace = generateDirectory.getNamespace()
    nom = generateDirectory.getNom()

    Path(directory).mkdir(parents=True, exist_ok=True)

    with open(directory+"/Gestion"+nom+"Service.php","x", encoding='utf-8') as file:
        file.write("<?php\n\n")
        file.write("namespace "+namespace+";\n\n")
        file.write("class Gestion"+nom+"Service\n")
        file.write("{\n\n")
        file.write("    public function __construct(\PDO $pdo)\n")
        file.write("    {\n")
        file.write("    }\n\n")
        file.write("    public function gestion"+nom+"()\n")
        file.write("    {\n")
        file.write("        return true;\n")
        file.write("    }\n\n")
        file.write("}\n")
        file.close()

