AdsUserTest::createTempSettingsFile PHP Метод

createTempSettingsFile() приватный Метод

Creates a temporary settings file from the array of settings provided.
private createTempSettingsFile ( array $settings ) : string
$settings array the settings to use
Результат string the path to the temp file
    private function createTempSettingsFile(array $settings)
    {
        $filePath = tempnam(sys_get_temp_dir(), 'settings.ini.');
        $file = fopen($filePath, 'w');
        foreach ($settings as $section => $properties) {
            fwrite($file, sprintf("[%s]\n", $section));
            foreach ($properties as $name => $value) {
                if ($value === false) {
                    $value = '0';
                }
                fwrite($file, sprintf("%s = '%s'\n", $name, $value));
            }
        }
        fclose($file);
        return $filePath;
    }