<commit_before><?php
/**
 * Created by IntelliJ IDEA.
 * User: onigoetz
 * Date: 16.02.14
 * Time: 23:10
 */

namespace Rocket\UI\Forms\Validators;


class CodeIgniterFormValidator implements ValidatorInterface
{
    public function hasError($name)
    {
        return form_field_error($name);
    }

    public function getRules($name)
    {
        if(!function_exists('CI')) {
            return [];
        }

        $OBJ = & _get_validation_object();

        //TODO :: add a list of available and unavaiable callbacks / validators ...

        if ($OBJ !== false) {
            return $OBJ->get_rules($name);
        }

        return;
    }
}<commit_msg>[Forms] Better checks for CI existence<commit_after><?php
/**
 * Created by IntelliJ IDEA.
 * User: onigoetz
 * Date: 16.02.14
 * Time: 23:10
 */

namespace Rocket\UI\Forms\Validators;


class CodeIgniterFormValidator implements ValidatorInterface
{
    public function hasError($name)
    {
        return form_field_error($name);
    }

    public function getRules($name)
    {
        if (!method_exists('Controller', 'get_instance')) {
            return [];
        }

        $OBJ = & _get_validation_object();

        //TODO :: add a list of available and unavaiable callbacks / validators ...

        if ($OBJ !== false) {
            return $OBJ->get_rules($name);
        }

        return;
    }
}
{'fraction_non_alphanumeric': 0.12445414847161572, 'fraction_numerical': 0.01455604075691412, 'mean_word_length': 2.258293838862559, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6195813', 'n_tokens_mistral': 442, 'n_tokens_neox': 406, 'n_words': 97}