<commit_before><?php

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

namespace dayax\core;

use dayax\core\Message;

/**
 * Exception Class.
 *
 * @author <NAME> <<EMAIL>>
 */
class Exception extends \Exception {

    static private $_splClasses = null;
    static private $_packages = array(
        'dayax',
    );

    public function __construct() {
        $message = Message::translateMessage(func_get_args());        
        parent::__construct($message);
    }

    static public function registerAutoload() {
        $autoloads = spl_autoload_functions();        
        $callback = array('dayax\core\Exception', 'loadClass');
        if (!in_array($callback, $autoloads)) {
            spl_autoload_register($callback);
        }
    }

    static public function addPackage($name) {
        if (!in_array($name, self::$_packages)) {
            self::$_packages[] = $name;
        }
    }

    static public function loadClass($class) {
                
        if (false === strpos($class, "\\") || false === strpos($class, 'Exception')) {
            return;
        }        
        $exp = explode("\\", $class);        
        if (!in_array($exp[0], self::$_packages)) {
            return;
        }        
        if (is_null(self::$_splClasses)) {
            self::$_splClasses = array();
            foreach (spl_classes() as $splClass) {
                if (false !== strpos($splClass, 'Exception')) {
                    if (!in_array($splClass, self::$_splClasses)) {
                        self::$_splClasses[] = $splClass;
                    }
                }
            }
        }
        
        $pos = strrpos($class, '\\');
        $exception = substr($class, $pos + 1);
        $namespace = substr($class, 0, $pos);
        $extends = in_array($exception, self::$_splClasses) ? '\\' . $exception : "\\Exception";
        $tpl = <<<EOC

    namespace $namespace{
    use dayax\core\Message;
    class $exception extends $extends
    {
        public function __construct()
        {
            \$message = Message::translateMessage(func_get_args());            
            parent::__construct(\$message);
        }
    }
    }//end of namespace;
EOC;
        
        eval($tpl);        
    }

}<commit_msg>fix message<commit_after><?php

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

namespace dayax\core;

use dayax\core\Message;

/**
 * Exception Class.
 *
 * @author <NAME> <<EMAIL>>
 */
class Exception extends \Exception {

    static private $_splClasses = null;
    static private $_packages = array(
        'dayax',
    );
    
    public function __construct() {        
        $message = Message::translateMessage(func_get_args());        
        parent::__construct($message);
    }

    static public function registerAutoload() {
        $autoloads = spl_autoload_functions();        
        $callback = array('dayax\core\Exception', 'loadClass');
        if (!in_array($callback, $autoloads)) {
            spl_autoload_register($callback);
        }
    }

    static public function addPackage($name) {
        if (!in_array($name, self::$_packages)) {
            self::$_packages[] = $name;
        }
    }

    static public function loadClass($class) {
                
        if (false === strpos($class, "\\") || false === strpos($class, 'Exception')) {
            return;
        }        
        $exp = explode("\\", $class);        
        if (!in_array($exp[0], self::$_packages)) {
            return;
        }        
        if (is_null(self::$_splClasses)) {
            self::$_splClasses = array();
            foreach (spl_classes() as $splClass) {
                if (false !== strpos($splClass, 'Exception')) {
                    if (!in_array($splClass, self::$_splClasses)) {
                        self::$_splClasses[] = $splClass;
                    }
                }
            }
        }
        
        $pos = strrpos($class, '\\');
        $exception = substr($class, $pos + 1);
        $namespace = substr($class, 0, $pos);
        $extends = in_array($exception, self::$_splClasses) ? '\\' . $exception : "\\Exception";
        $tpl = <<<EOC

    namespace $namespace{
    use dayax\core\Message;
    class $exception extends $extends
    {
        public function __construct()
        {
            \$message = Message::translateMessage(func_get_args());            
            parent::__construct(\$message);
        }
    }
    }//end of namespace;
EOC;
        
        eval($tpl);        
    }
    
}
{'fraction_non_alphanumeric': 0.14427449359239355, 'fraction_numerical': 0.0012401818933443572, 'mean_word_length': 1.8498233215547704, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 15, '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': '5690714', 'n_tokens_mistral': 1373, 'n_tokens_neox': 1346, 'n_words': 305}