generator/src/FileCreator.php
public function generatePhpFile(array $functions, string $path): void
    {
        $path = rtrim($path, '/').'/';
        $phpFunctionsByModule = [];
        foreach ($functions as $function) {
            $writePhpFunction = new WritePhpFunction($function);
            $phpFunctionsByModule[$function->getModuleName()][] = $writePhpFunction->getPhpFunctionalFunction();
        }

        foreach ($phpFunctionsByModule as $module => $phpFunctions) {
            $lcModule = \lcfirst($module);
            $stream = \fopen($path.$lcModule.'.php', 'w');
            if ($stream === false) {
                throw new \RuntimeException('Unable to write to '.$path);
            }
            \fwrite($stream, "<?php\n
namespace Safe;

use Safe\\Exceptions\\".self::toExceptionName($module). ';

');
            foreach ($phpFunctions as $phpFunction) {
                \fwrite($stream, $phpFunction."\n");
            }
            \fclose($stream);
        }
    }
public function generatePhpFile(array $functions, string $path): void
    {
        $path = rtrim($path, '/').'/';
        $phpFunctionsByModule = [];
        foreach ($functions as $function) {
            $writePhpFunction = new WritePhpFunction($function);
            $phpFunctionsByModule[$function->getModuleName()][] = $writePhpFunction->getPhpFunctionalFunction();
        }

        foreach ($phpFunctionsByModule as $module => $phpFunctions) {
            $lcModule = \lcfirst($module);
            $stream = \fopen($path.$lcModule.'.php', 'w');
            if ($stream === false) {
                throw new \RuntimeException('Unable to write to '.$path);
            }
            \fwrite($stream, "<?php\n
namespace Safe;

use Safe\\Exceptions\\".self::toExceptionName($module). ';

');
            foreach ($phpFunctions as $phpFunction) {
                \fwrite($stream, $phpFunction."\n");
            }
            \fclose($stream);
        }
    }
public function generatePhpFile ( array $ functions , string $ path ) : void { $ path = rtrim ( $ path , '/' ) . '/' ; $ phpFunctionsByModule = [ ] ; foreach ( $ functions as $ function ) { $ writePhpFunction = new WritePhpFunction ( $ function ) ; $ phpFunctionsByModule [ $ function -> getModuleName ( ) ] [ ] = $ writePhpFunction -> getPhpFunctionalFunction ( ) ; } foreach ( $ phpFunctionsByModule as $ module => $ phpFunctions ) { $ lcModule = \ lcfirst ( $ module ) ; $ stream = \ fopen ( $ path . $ lcModule . '.php' , 'w' ) ; if ( $ stream === false ) { throw new \ RuntimeException ( 'Unable to write to ' . $ path ) ; } \ fwrite ( $ stream , "<?php\n
namespace Safe;

use Safe\\Exceptions\\" . self :: toExceptionName ( $ module ) . ';

' ) ; foreach ( $ phpFunctions as $ phpFunction ) { \ fwrite ( $ stream , $ phpFunction . "\n" ) ; } \ fclose ( $ stream ) ; } }
This function generate an improved php lib function in a php file

@param Method[] $functions
@param string $path
This function generate an improved php lib function in a php file