<commit_before><?php
namespace system;

use Valitron\Validator;

class BaseModel {

    public function __get($key)
    {
        $attribute = 'get' . $key;
        if (method_exists($this, $attribute)) {
            return $this->$attribute();
        } else {
            throw new \Exception("Can't get $key");
        }
    }

    public function __set($key, $value)
    {
        $attribute = 'set' . $key;
        if (method_exists($this, $attribute)) {
            $this->$attribute($value);
        } else {
            throw new \Exception("Can't set $key");
        }
    }

    public static function className()
    {
        return get_called_class();
    }

    public function rules()
    {
        return [];
    }

    public function validate($datas = [])
    {
        foreach (get_class_methods($this) as $funcRule) {
            if (substr($funcRule, 0, 4) == 'rule' && $funcRule != 'rules') {
                call_user_func_array('\Valitron\Validator::addRule', $this->$funcRule());
            }
        }

        if ($datas == null)
            $datas = get_object_vars($this);

        $validator = new Validator($datas);
        foreach ($this->rules() as $args) {
            call_user_func_array([$validator, 'rule'], $args);
        }
        if ($validator->validate()) {
            return true;
        }
        return $validator->errors();
    }

}<commit_msg>fix args for call Validator::addRule function on BaseModel<commit_after><?php
namespace system;

use Valitron\Validator;

class BaseModel {

    public function __get($key)
    {
        $attribute = 'get' . $key;
        if (method_exists($this, $attribute)) {
            return $this->$attribute();
        } else {
            throw new \Exception("Can't get $key");
        }
    }

    public function __set($key, $value)
    {
        $attribute = 'set' . $key;
        if (method_exists($this, $attribute)) {
            $this->$attribute($value);
        } else {
            throw new \Exception("Can't set $key");
        }
    }

    public static function className()
    {
        return get_called_class();
    }

    public function rules()
    {
        return [];
    }

    public function validate($datas = [])
    {
        foreach (get_class_methods($this) as $funcRule) {
            if (substr($funcRule, 0, 4) == 'rule' && $funcRule != 'rules') {
                call_user_func_array('\Valitron\Validator::addRule', array_unshift($this->$funcRule(), substr($funcRule, 4)));
            }
        }

        if ($datas == null)
            $datas = get_object_vars($this);

        $validator = new Validator($datas);
        foreach ($this->rules() as $args) {
            call_user_func_array([$validator, 'rule'], $args);
        }
        if ($validator->validate()) {
            return true;
        }
        return $validator->errors();
    }

}
{'fraction_non_alphanumeric': 0.14867688022284123, 'fraction_numerical': 0.0017409470752089136, 'mean_word_length': 1.9197154471544715, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7619334', 'n_tokens_mistral': 855, 'n_tokens_neox': 832, 'n_words': 185}