<commit_before><?php

namespace k1lib\controllers;

/**
 * Return the controller PATH for include it, we cant do it from the function by the var scope, so we do here some esential checks before the include
 * @global array $url_data url_rewrite data variable from K1FW
 * @param string $controller_name Just the file name 
 * @return string correct path to include the file name recived on $controller_name
 */
function load_controller($controller_name, $query_auto_load = TRUE) {
    global $url_data, $controller_query_file;
    $controller_query_file = FALSE;
    if (is_string($controller_name)) {
        // Try with subfolder scheme
        $controller_subfix = \k1app\APP_CONTROLLERS_PATH . "/{$controller_name}";

        $controller_to_load = $controller_subfix . "/index.php";
        if (file_exists($controller_to_load)) {
            // QUERY Auto load
            if ($query_auto_load) {
                $last_controles_name = basename($controller_name);
                $query_to_load = "{$controller_subfix}/query/{$last_controles_name}.php";
                if (file_exists($query_to_load)) {
                    $controller_query_file = $query_to_load;
                }
            }
            return $controller_to_load;
        } else {
            // Try with single file scheme
            $controller_to_load = $controller_subfix . ".php";
            if (file_exists($controller_to_load)) {
                // QUERY Auto load
                if ($query_auto_load) {
                    $last_controles_name = basename(($controller_name));
                    $query_to_load = dirname($controller_subfix) . "/query/{$last_controles_name}.php";
                    if (file_exists($query_to_load)) {
                        $controller_query_file = $query_to_load;
                    }
                }
                return $controller_to_load;
            } else {
                die("The controller '{$controller_name}' could not be found " . __FUNCTION__);
            }
        }
    } else {
        die("The controller name value only can be string");
        exit;
    }
}

/**
 * Check if the controller exist on the designed path on the K1FW config (APP_CONTROLLERS_PATH)
 * @global array $url_data url_rewrite data variable from K1FW
 * @param string $controller_name Just the file name 
 * @return boolean tell if exist or not the file on $controller_name
 */
function if_exist_controller($controller_name) {
    if (is_string($controller_name)) {
        $controller_to_load = APP_CONTROLLERS_PATH . "/{$controller_name}.php";
        if (file_exists($controller_to_load)) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
}
<commit_msg>Controllers documented<commit_after><?php
/**
 * Controller related functions, K1.lib.
 * 
 * This are my controller use propose.
 * @author J0hnD03 <<EMAIL>>
 * @version 1.0
 * @package controllers
 */
namespace k1lib\controllers;

/**
 * Return the controller PATH for include it, we cant do it from the function by the var scope, so we do here some esential checks before the include
 * @global array $url_data url_rewrite data variable from K1FW
 * @param string $controller_name Just the file name 
 * @return string correct path to include the file name recived on $controller_name
 */
//function load_controller($controller_name, $query_auto_load = TRUE) {
function load_controller($controller_name, $controllers_path) {
    $controller_query_file = FALSE;
    if (is_string($controller_name)) {
        // Try with subfolder scheme
        $controller_subfix = $controllers_path . "/{$controller_name}";

        $controller_to_load = $controller_subfix . ".php";
        if (file_exists($controller_to_load)) {
            return $controller_to_load;
        } else {
            // Try with single file scheme
            $controller_to_load = $controller_subfix . "/index.php";
            if (file_exists($controller_to_load)) {
                // QUERY Auto load
                return $controller_to_load;
            } else {
                \trigger_error("The controller '{$controller_name}' could not be found", E_USER_ERROR);
            }
        }
    } else {
        \trigger_error("The controller name value only can be string", E_USER_ERROR);
        exit;
    }
}
{'fraction_non_alphanumeric': 0.09316914498141264, 'fraction_numerical': 0.0030204460966542753, 'mean_word_length': 2.435754189944134, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '3802671', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1176, 'n_words': 333}