<commit_before><?php

function checkActive($route = '')
{
    $url = parse_url($route);
    $path = trim($url['path'], '/');
    return request()->is($path . '*');
}

function checkRule($rules = [])
{
    $user = auth()->user();

    if ($user->role_id == 0) {
        return false;
    }

    if (auth()->user()->role()->first() == null) {
        return true;
    }

    if (!is_array($rules)) $rules = [$rules];

    $userRules = auth()->user()->role()->first()->rules;
    foreach ($rules as $rule) {
        if (in_array($rule, $userRules)) {
            return false;
        }
    }

    return true;
}

function columnSort($title, $parameters, $icon = 'fa-sort')
{
    $field = request()->get('field');
    $sort = request()->get('sort');

    if ($sort == 'asc') {
        $parameters['sort'] = 'desc';
    } else {
        $parameters['sort'] = 'asc';
    }

    if ($field == $parameters['field']) {
        $icon = sprintf('fa %s-%s', $icon, $parameters['sort']);
    } else {
        $icon = sprintf('fa %s', $icon);
    }

    $queryString = request()->getQueryString();
    parse_str($queryString, $query);
    unset($query['page']);
    unset($query['field']);
    unset($query['sort']);
    $fullUrl = request()->url() . '?' . http_build_query($query + $parameters);


    return sprintf('<a href="%s">%s <i class="%s"></i></a>', $fullUrl, $title, $icon);
}<commit_msg>Helper de formatação de valores<commit_after><?php

function checkActive($route = '')
{
    $url = parse_url($route);
    $path = trim($url['path'], '/');
    return request()->is($path . '*');
}

function checkRule($rules = [])
{
    $user = auth()->user();

    if ($user->role_id == 0) {
        return false;
    }

    if (auth()->user()->role()->first() == null) {
        return true;
    }

    if (!is_array($rules)) $rules = [$rules];

    $userRules = auth()->user()->role()->first()->rules;
    foreach ($rules as $rule) {
        if (in_array($rule, $userRules)) {
            return false;
        }
    }

    return true;
}

function columnSort($title, $parameters, $icon = 'fa-sort')
{
    $field = request()->get('field');
    $sort = request()->get('sort');

    if ($sort == 'asc') {
        $parameters['sort'] = 'desc';
    } else {
        $parameters['sort'] = 'asc';
    }

    if ($field == $parameters['field']) {
        $icon = sprintf('fa %s-%s', $icon, $parameters['sort']);
    } else {
        $icon = sprintf('fa %s', $icon);
    }

    $queryString = request()->getQueryString();
    parse_str($queryString, $query);
    unset($query['page']);
    unset($query['field']);
    unset($query['sort']);
    $fullUrl = request()->url() . '?' . http_build_query($query + $parameters);


    return sprintf('<a href="%s">%s <i class="%s"></i></a>', $fullUrl, $title, $icon);
}

function formatToNumber($number, $prefix = false)
{
    return (isset($number) && (substr($number, -3, 1) != ',')) ? $prefix . number_format($number, 2, ',', '.') : $number;
}

function formatToFloat($number)
{
    return ($number) ? str_replace(',', '.', str_replace('.', '', trim(str_replace('R$', '', $number)))) : null;
}
{'fraction_non_alphanumeric': 0.2431825473211421, 'fraction_numerical': 0.0016041065126724415, 'mean_word_length': 2.9770408163265305, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 39, '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': '4698942', 'n_tokens_mistral': 1037, 'n_tokens_neox': 1024, 'n_words': 204}