<commit_before><?php
/**
 * Auth - A simple Auth Facade.
 *
 * @author <NAME> - <EMAIL>
 * @version 3.0
 */

namespace Auth;

use Core\Config;

use \Closure;


class Auth
{
    /**
     * The currently active Authentication Guards.
     *
     * @var array
     */
     public static $guards = array();

    /**
     * The third-party Guard Registrar.
     *
     * @var array
     */
    public static $registrar = array();

    /**
     * Get an Authentication Guard instance.
     *
     * @param  string  $guard
     * @return Guard
     */
    public static function guard($guard = null)
    {
        $guard = ($guard !== null) ? $guard : 'native';

        if ( ! isset(static::$guards[$guard])) {
            static::$guards[$guard] = static::factory($guard);
        }

        return static::$guards[$guard];
    }

    /**
     * Create a new Authentication Guard instance.
     *
     * @param  string  $guard
     * @return Guard
     */
     protected static function factory($guard)
     {
         if (isset(static::$registrar[$guard])) {
            $resolver = static::$registrar[$guard];

            return call_user_func($resolver);
         }

         $config = Config::get('authentication');

         switch ($guard) {
            case 'native':
                return new \Auth\Guard($config);

            default:
                throw new \Exception("Auth Guard {$guard} is not supported.");
         }
    }

    /**
     * Register a third-party Authentication Guard.
     *
     * @param  string   $guard
     * @param  Closure  $resolver
     * @return void
     */
    public static function extend($guard, Closure $resolver)
    {
        static::$registrar[$guard] = $resolver;
    }

    /**
     * Magic Method for calling the methods on the default cache Guard.
     *
     * <code>
     *      // Call the "user" method on the default Auth Guard
     *      $user = Auth::user();
     *
     *      // Call the "check" method on the default Auth Guard
     *      Auth::check();
     * </code>
     *
     * @param  string $method
     * @param  array  $params
     * @return mixed
     */
    public static function __callStatic($method, $params)
    {
        return call_user_func_array(array(static::guard(), $method), $params);
    }
}
<commit_msg>Improve Auth\Auth@factory<commit_after><?php
/**
 * Auth - A simple Auth Facade.
 *
 * @author <NAME> - <EMAIL>
 * @version 3.0
 */

namespace Auth;

use Core\Config;

use \Closure;


class Auth
{
    /**
     * The currently active Authentication Guards.
     *
     * @var array
     */
     public static $guards = array();

    /**
     * The third-party Guard Registrar.
     *
     * @var array
     */
    public static $registrar = array();

    /**
     * Get an Authentication Guard instance.
     *
     * @param  string  $guard
     * @return Guard
     */
    public static function guard($guard = null)
    {
        $guard = ($guard !== null) ? $guard : 'native';

        if ( ! isset(static::$guards[$guard])) {
            static::$guards[$guard] = static::factory($guard);
        }

        return static::$guards[$guard];
    }

    /**
     * Create a new Authentication Guard instance.
     *
     * @param  string  $guard
     * @return Guard
     */
    protected static function factory($guard)
    {
        if (isset(static::$registrar[$guard])) {
            $resolver = static::$registrar[$guard];

            return call_user_func($resolver);
        } else if($guard == 'native') {
            $config = Config::get('authentication');

            return new \Auth\Guard($config);
        }

        throw new \Exception("Auth Guard {$guard} is not supported.");
    }

    /**
     * Register a third-party Authentication Guard.
     *
     * @param  string   $guard
     * @param  Closure  $resolver
     * @return void
     */
    public static function extend($guard, Closure $resolver)
    {
        static::$registrar[$guard] = $resolver;
    }

    /**
     * Magic Method for calling the methods on the default cache Guard.
     *
     * <code>
     *      // Call the "user" method on the default Auth Guard
     *      $user = Auth::user();
     *
     *      // Call the "check" method on the default Auth Guard
     *      Auth::check();
     * </code>
     *
     * @param  string $method
     * @param  array  $params
     * @return mixed
     */
    public static function __callStatic($method, $params)
    {
        return call_user_func_array(array(static::guard(), $method), $params);
    }
}

{'fraction_non_alphanumeric': 0.12984822934232715, 'fraction_numerical': 0.0008431703204047217, 'mean_word_length': 1.6687289088863893, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '5408387', 'n_tokens_mistral': 1437, 'n_tokens_neox': 1329, 'n_words': 353}