<commit_before><?php

/*
 * This file is part of the Build package.
 *
 * (c) Centagon <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

if ( ! function_exists('alert')) {
    /**
     * @return Build\Core\Support\Alert\MessageBag
     */
    function alert()
    {
        return app('build.alert');
    }
}

if ( ! function_exists('build_route_string')) {
    /**
     * Generate a named route string.
     *
     * @param  string  $name
     *
     * @return string
     * @deprecated 2.0
     */
    function build_route_string($name)
    {
        return 'admin.' . $name;
    }
}

if ( ! function_exists('build_route')) {
    /**
     * Generate a URL to a named route.
     *
     * @param  string  $name
     * @param  array   $parameters
     * @param  bool    $absolute
     *
     * @return string
     * @deprecated 2.0
     */
    function build_route($name, $parameters = [], $absolute = true)
    {
        return route(build_route_string($name), $parameters, $absolute);
    }
}

if ( ! function_exists('entity')) {
    /**
     * @param  string  $entity
     * @param  null|string  $method
     *
     * @return \Build\Core\Bauhaus\Manager
     */
    function entity($entity, $method = null)
    {
        return (new Build\Core\Bauhaus\Factory)->make($entity, $method);
    }
}

if ( ! function_exists('get_traits')) {
    /**
     * Get all traits defined on the given class.
     *
     * @param  string  $class
     *
     * @return Generator
     */
    function get_traits($class)
    {
        if ( ! is_string($class)) {
            $class = get_class($class);
        }

        foreach (class_uses_recursive($class) as $trait) {
            yield class_basename($trait);
        }
    }
}

if ( ! function_exists('has_trait')) {
    /**
     * Determine that the given trait exists on the given instance.
     *
     * @param  mixed   $instance
     * @param  string  $whichTrait
     *
     * @return bool
     */
    function has_trait($instance, $whichTrait)
    {
        $baseTrait = class_basename($whichTrait);

        foreach (get_traits($instance) as $trait) {
            if (($trait == $whichTrait) || ($trait == $baseTrait)) {
                return true;
            }
        }

        return false;
    }
}

if ( ! function_exists('module_path')) {
    /**
     *
     */
    function module_path($slug)
    {
        $path = config('build.core.modules-path');

        $module = \Build\Core\Support\Facades\Modules::where('slug', $slug);

        return $path . '/' . $module['basename'];
    }
}

if ( ! function_exists('try_method')) {
    /**
     * Test the existence of a certain method and try calling it when it does exist.
     *
     * @param  \Build\Core\Eloquent\Model  $instance
     * @param  string  $method
     * @param  array   $parameters
     */
    function try_method($instance, $method, array $parameters = [])
    {
        if (method_exists($instance, $method)) {
            call_user_func_array([$instance, $method], $parameters);
        }
    }
}

if (!function_exists('form_select')) {

    function form_select($name, $options = [], $default = '', $attr = [])
    {
        $attributes = [];
        
        foreach ($attr as $key => $value) {
            $attributes[] = "{$key}=\"$value\"";
        }
        
        $attributes = implode(' ', $attributes);
        
        $multiple = array_get($attr, 'multiple', false);
        
        if ($multiple) {
            
            if (empty($default)) {
                $default = [];<commit_msg>added the missing translation helper method<commit_after><?php

/*
 * This file is part of the Build package.
 *
 * (c) Centagon <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

use Build\Content\Support\Facades\Discovery;
use Build\Core\Eloquent\Models\Language\Entry;

if ( ! function_exists('alert')) {
    /**
     * @return Build\Core\Support\Alert\MessageBag
     */
    function alert()
    {
        return app('build.alert');
    }
}

if ( ! function_exists('build_route_string')) {
    /**
     * Generate a named route string.
     *
     * @param  string  $name
     *
     * @return string
     * @deprecated 2.0
     */
    function build_route_string($name)
    {
        return 'admin.' . $name;
    }
}

if ( ! function_exists('build_route')) {
    /**
     * Generate a URL to a named route.
     *
     * @param  string  $name
     * @param  array   $parameters
     * @param  bool    $absolute
     *
     * @return string
     * @deprecated 2.0
     */
    function build_route($name, $parameters = [], $absolute = true)
    {
        return route(build_route_string($name), $parameters, $absolute);
    }
}

if ( ! function_exists('entity')) {
    /**
     * @param  string  $entity
     * @param  null|string  $method
     *
     * @return \Build\Core\Bauhaus\Manager
     */
    function entity($entity, $method = null)
    {
        return (new Build\Core\Bauhaus\Factory)->make($entity, $method);
    }
}

if ( ! function_exists('get_traits')) {
    /**
     * Get all traits defined on the given class.
     *
     * @param  string  $class
     *
     * @return Generator
     */
    function get_traits($class)
    {
        if ( ! is_string($class)) {
            $class = get_class($class);
        }

        foreach (class_uses_recursive($class) as $trait) {
            yield class_basename($trait);
        }
    }
}

if ( ! function_exists('has_trait')) {
    /**
     * Determine that the given trait exists on the given instance.
     *
     * @param  mixed   $instance
     * @param  string  $whichTrait
     *
     * @return bool
     */
    function has_trait($instance, $whichTrait)
    {
        $baseTrait = class_basename($whichTrait);

        foreach (get_traits($instance) as $trait) {
            if (($trait == $whichTrait) || ($trait == $baseTrait)) {
                return true;
            }
        }

        return false;
    }
}

if ( ! function_exists('module_path')) {
    /**
     *
     */
    function module_path($slug)
    {
        $path = config('build.core.modules-path');

        $module = \Build\Core\Support\Facades\Modules::where('slug', $slug);

        return $path . '/' . $module['basename'];
    }
}

if ( ! function_exists('try_method')) {
    /**
     * Test the existence of a certain method and try calling it when it does exist.
     *
     * @param  \Build\Core\Eloquent\Model  $instance
     * @param  string  $method
     * @param  array   $parameters
     */
    function try_method($instance, $method, array $parameters = [])
    {
        if (method_exists($instance, $method)) {
            call_user_func_array([$instance, $method], $parameters);
        }
    }
}

if (! function_exists('lang')) {

    function lang($label, $locale = null)
    {
        if ($locale === null && Discovery::website()) {
            $locale = Discovery::website()->language->locale;
        }

        $entry = (new Entry)->translate($label, $locale);

        if ($entry == $label) {
            return null;
        }

        return $entry;
    }
}

if (!function_exists('form_select')) {

    function form_select($name, $options = [], $default = '', $attr = [])
    {
        $attributes = [];
        
        foreach ($attr as $key => $value) {
            $attributes[] = "{$key}=\"$value\"";
        }
        
        $attributes = implode(' ', $attributes);
        
        $multiple = array_get($attr, 'multiple', false);
        
        if ($multiple) {
            
            if (empty($default)) {
                $default = [];
{'fraction_non_alphanumeric': 0.14575526553818322, 'fraction_numerical': 0.0010337252875048455, 'mean_word_length': 1.9861111111111112, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 14, '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': '1045532', 'n_tokens_mistral': 2370, 'n_tokens_neox': 2359, 'n_words': 528}