<commit_before><?php
/**
 * This file belongs to the AnoynmFramework
 *
 * @author vahitserifsaglam <<EMAIL>>
 * @see http://gemframework.com
 *
 * Thanks for using
 */

namespace Anonym\Patterns;

use Anonym\Bootstrap\AliasLoader;
use Anonym\Bootstrap\Container;
use InvalidArgumentException;
/**
 * Class Facade
 * @package Anonym\Patterns
 */
class Facade
{

    /**
     * the instance of container
     *
     * @var Container
     */
    protected static $container;

    /**
     * load the facade instance
     *
     * @return bool|Object
     * @throws FacadeException
     */
    private static function getContainer(){
        if (!static::$container instanceof Container) {
            static::$container = new Container();
        }

        return static::$container;
    }

    /**
     * get the facade class
     *
     * @throws FacadeException
     * @return string|Object
     */
    protected static function getFacadeClass()
    {
        throw new FacadeException('i can not call myself');
    }

    /**
     * do resolve returned value
     *
     * @param mixed $class
     * @throws InvalidArgumentException
     * @return Object|bool
     *
     */
    private static function resolveFacadeClass($class)
    {
        $class = is_string($class) ? $class : get_class($class);

        $container = static::getContainer();
        $container->singleton($class, function($abstract){
            if (is_string($abstract)) {
                return (new AliasLoader())->load($abstract);
            }elseif(is_object($abstract) && !$abstract instanceof Facade){
                return $abstract;
            }else{
                throw new InvalidArgumentException('Your class cant be an instance of facade or anything else');
            }
        });

        return $class;
    }

    /**
     * call the method in registered instances
     *
     * @param string $method the name of method
     * @param array $args the variables for method
     * @return mixed
     */
    public static function __callStatic($method, $args = [])
    {
        $class =  static::resolveFacadeClass(static::getFacadeClass());
        $instance = static::getContainer()->make($class);
        return call_user_func_array([$instance, $method], $args);
    }
    /**
     * call the method in registered instances
     *<commit_msg>fixed a little bug<commit_after><?php
/**
 * This file belongs to the AnoynmFramework
 *
 * @author vahitserifsaglam <<EMAIL>>
 * @see http://gemframework.com
 *
 * Thanks for using
 */

namespace Anonym\Patterns;

use Anonym\Bootstrap\AliasLoader;
use Anonym\Bootstrap\Container;
use InvalidArgumentException;
/**
 * Class Facade
 * @package Anonym\Patterns
 */
class Facade
{

    /**
     * the instance of container
     *
     * @var Container
     */
    protected static $container;

    /**
     * load the facade instance
     *
     * @return bool|Object
     * @throws FacadeException
     */
    private static function getContainer(){
        if (!static::$container instanceof Container) {
            static::$container = new Container();
        }

        return static::$container;
    }

    /**
     * get the facade class
     *
     * @throws FacadeException
     * @return string|Object
     */
    protected static function getFacadeClass()
    {
        throw new FacadeException('i can not call myself');
    }

    /**
     * do resolve returned value
     *
     * @param mixed $class
     * @throws InvalidArgumentException
     * @return Object|bool
     *
     */
    private static function resolveFacadeClass($class)
    {
        $class = is_string($class) ? $class : get_class($class);

        $container = static::getContainer();
        $container->singleton($class, function() use($class){
            if (is_string($class)) {
                return (new AliasLoader())->load($class);
            }elseif(is_object($class) && !$class instanceof Facade){
                return $class;
            }else{
                throw new InvalidArgumentException('Your class cant be an instance of facade or anything else');
            }
        });

        return $class;
    }

    /**
     * call the method in registered instances
     *
     * @param string $method the name of method
     * @param array $args the variables for method
     * @return mixed
     */
    public static function __callStatic($method, $args = [])
    {
        $class =  static::resolveFacadeClass(static::getFacadeClass());
        $instance = static::getContainer()->make($class);
        return call_user_func_array([$instance, $method], $args);
    }
    /**
     * call the method in registered instances
     *
{'fraction_non_alphanumeric': 0.11470147656751552, 'fraction_numerical': 0.0, 'mean_word_length': 2.2938689217758985, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '753072', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1245, 'n_words': 342}