<commit_before><?php

namespace Transitive\Core\Install;

use Composer\Script\Event;

class ScriptHandler
{
    private static function _copyDirectory(string $source, string $dest) {
        $dir = opendir($source);
        @mkdir($dest);
        while(false !== ($file = readdir($dir))) {
            if ($file != '.' && $file != '..') {
                if (is_dir($source.'/'.$file))
                    self::_copyDirectory($source.'/'.$file, $dest.'/'.$file);
                elseif(!file_exists($dest.'/'.$file)) {
                    copy($source.'/'.$file, $dest.'/'.$file);
                    echo ' + copying: ', $dest.'/'.$file, PHP_EOL;
                }
            }
        }
        closedir($dir);
    }

    public static function setFiles(array $files, $from = null) {
        $from = $from ?? dirname(dirname(__FILE__));

        foreach($files as $dest) {
            if(is_array($dest)) {
                $source = $from.'/'.$dest[0];
                $dest = $dest[1];
            }  else
                $source = $from.'/'.$dest;

            if(is_file($source) && !file_exists($dest)) {
                copy($source, $dest);
                echo ' + copying: ', $dest, PHP_EOL;
            } elseif(is_dir($source))
                self::_copyDirectory($source, $dest);
        }
    }

    public static function setup(Event $event)
    {
        @mkdir('config');
        self::setFiles([
            'presenters',
            'views',
        ]);

        if(!file_exists('www') && !file_exists('public_html')) {
            @mkdir('htdocs');
            self::setFiles(['htdocs/index.php']);<commit_msg>Remove default config folder<commit_after><?php

namespace Transitive\Core\Install;

use Composer\Script\Event;

class ScriptHandler
{
    private static function _copyDirectory(string $source, string $dest) {
        $dir = opendir($source);
        @mkdir($dest);
        while(false !== ($file = readdir($dir))) {
            if ($file != '.' && $file != '..') {
                if (is_dir($source.'/'.$file))
                    self::_copyDirectory($source.'/'.$file, $dest.'/'.$file);
                elseif(!file_exists($dest.'/'.$file)) {
                    copy($source.'/'.$file, $dest.'/'.$file);
                    echo ' + copying: ', $dest.'/'.$file, PHP_EOL;
                }
            }
        }
        closedir($dir);
    }

    public static function setFiles(array $files, $from = null) {
        $from = $from ?? dirname(dirname(__FILE__));

        foreach($files as $dest) {
            if(is_array($dest)) {
                $source = $from.'/'.$dest[0];
                $dest = $dest[1];
            }  else
                $source = $from.'/'.$dest;

            if(is_file($source) && !file_exists($dest)) {
                copy($source, $dest);
                echo ' + copying: ', $dest, PHP_EOL;
            } elseif(is_dir($source))
                self::_copyDirectory($source, $dest);
        }
    }

    public static function setup(Event $event)
    {
        self::setFiles([
            'presenters',
            'views',
        ]);

        if(!file_exists('www') && !file_exists('public_html')) {
            @mkdir('htdocs');
            self::setFiles(['htdocs/index.php']);
{'fraction_non_alphanumeric': 0.18125960061443933, 'fraction_numerical': 0.001228878648233487, 'mean_word_length': 1.679835390946502, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3494172', 'n_tokens_mistral': 966, 'n_tokens_neox': 948, 'n_words': 161}