<commit_before><?php

namespace Framework\Shell;

use \Exception;
use Framework\Common\File;

/**
 * Class Cmd.
 *
 * @category PHP
 */
class Cmd
{
    private function __construct()
    {
        // It should never be used.
    }

    /**
     * Cli init.
     *
     * @param string $conf Config path.
     *
     * @return void
     */
    public static function init($conf)
    {
        $conf = parse_ini_file($conf, true);

        $mode = isset($conf['base']['mode']) ? $conf['base']['mode'] : 'restful';
        $root = isset($conf['base']['root']) ? $conf['base']['root'] : '';

        if (!is_dir($root)) {
            throw new Exception("Please check your config, '($root)' is not exist");
        }

        $root = rtrim($root, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;

        $run = $root . 'run';
        $log = $root . 'log';

        is_dir($run) || File::makeDir($run);
        is_dir($log) || File::makeDir($log);

        if (!isset($conf[$mode])) {
            throw new Exception("Not found the mode ['{$mode}']");
        }

        $conf = $conf[$mode];

        switch ($mode) {
            case 'restful':
                self::initRestful($conf, $root);
                break;

            default:
                break;
        }
    }

    private static function initRestful($conf, $root)
    {
        $restful_root = $root . 'restful' . DIRECTORY_SEPARATOR;

        $resource_root = $restful_root . 'Resource';
        $model_root = $restful_root . 'Model';

        is_dir($resource_root) || File::makeDir($resource_root);
        is_dir($model_root) || File::makeDir($model_root);

        echo PHP_EOL . 'Init restful OK' . PHP_EOL;
    }
}

// end of script<commit_msg>update cmd<commit_after><?php

namespace Framework\Shell;

use \Exception;
use Framework\Common\File;

/**
 * Class Cmd.
 *
 * @category PHP
 */
class Cmd
{
    private function __construct()
    {
        // It should never be used.
    }

    /**
     * Cli init.
     *
     * @param string $conf Config path.
     *
     * @return void
     */
    public static function init($conf)
    {
        $conf = parse_ini_file($conf, true);

        $mode = isset($conf['base']['mode']) ? $conf['base']['mode'] : 'restful';
        $root = isset($conf['base']['root']) ? $conf['base']['root'] : '';

        if (!is_dir($root)) {
            throw new Exception("Please check your config, '($root)' is not exist");
        }

        $root = rtrim($root, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;

        $run = $root . 'run';
        $log = $root . 'log';

        is_dir($run) || File::makeDir($run);
        is_dir($log) || File::makeDir($log);

        if (!isset($conf[$mode])) {
            throw new Exception("Not found the mode ['{$mode}']");
        }

        $conf = $conf[$mode];

        switch ($mode) {
            case 'restful':
                self::initRestful($conf, $root);
                break;

            default:
                break;
        }
    }

    private static function initRestful($conf, $root)
    {
        $restful_root = $root . 'restful' . DIRECTORY_SEPARATOR;

        is_dir($restful_root) || File::makeDir($restful_root);

        $resource_root = $restful_root . 'Resource';
        $model_root = $restful_root . 'Model';

        is_dir($resource_root) || File::makeDir($resource_root);
        is_dir($model_root) || File::makeDir($model_root);

        echo PHP_EOL . 'Init restful OK' . PHP_EOL;
    }
}

// end of script
{'fraction_non_alphanumeric': 0.16489819328936048, 'fraction_numerical': 0.0, 'mean_word_length': 2.0650263620386644, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1671670', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1083, 'n_words': 238}