<commit_before><?php

/**
 * This file is part of the Propel package.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @license MIT License
 */

namespace Propel\Generator\Behavior\Validate;

use Propel\Generator\Exception\ConstraintNotFoundException;
use Propel\Generator\Exception\InvalidArgumentException;
use Propel\Generator\Model\Behavior;
use Symfony\Component\Yaml\Parser;

/**
 * Validate a model object using Symfony2 Validator component
 *
 * @author <NAME>
*/
class ValidateBehavior extends Behavior
{
    /**
     * @param object $builder The current builder
     */
    protected $builder;

    /**
     * Add behavior methods to model class
     *
     * @return string
     */
    public function objectMethods($builder)
    {
        $array = $this->getParameters();
        if (empty($array)) {
            throw new InvalidArgumentException('Please, define your rules for validation.');
        }
        $this->cleanupParameters();

        $this->builder = $builder;
        $this->builder->declareClasses(
            'Symfony\\Component\\Validator\\Mapping\\ClassMetadata',
            'Symfony\\Component\\Validator\\DefaultTranslator',
            'Symfony\\Component\\Validator\\Mapping\\Loader\\StaticMethodLoader',
            'Symfony\\Component\\Validator\\ConstraintValidatorFactory',
            'Symfony\\Component\\Validator\\ConstraintViolationList'
        );

        //if SF >= 2.5 use new validator classes
        if(class_exists('Symfony\\Component\\Validator\\Validator\\RecursiveValidator')) {
            $this->builder->declareClasses(
                'Symfony\\Component\\Validator\\Validator\\RecursiveValidator',
                'Symfony\\Component\\Validator\\Context\\ExecutionContextFactory',
                'Symfony\\Component\\Validator\\Mapping\\Factory\LazyLoadingMetadataFactory',
                'Symfony\\Component\\Validator\\Context\\ExecutionContextInterface',
                'Symfony\\Component\\Validator\\Validator\\ValidatorInterface',
                'Symfony\\Component\\Translation\\IdentityTranslator'<commit_msg>What if we don't use the translator?<commit_after><?php

/**
 * This file is part of the Propel package.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @license MIT License
 */

namespace Propel\Generator\Behavior\Validate;

use Propel\Generator\Exception\ConstraintNotFoundException;
use Propel\Generator\Exception\InvalidArgumentException;
use Propel\Generator\Model\Behavior;
use Symfony\Component\Yaml\Parser;

/**
 * Validate a model object using Symfony2 Validator component
 *
 * @author <NAME>
*/
class ValidateBehavior extends Behavior
{
    /**
     * @param object $builder The current builder
     */
    protected $builder;

    /**
     * Add behavior methods to model class
     *
     * @return string
     */
    public function objectMethods($builder)
    {
        $array = $this->getParameters();
        if (empty($array)) {
            throw new InvalidArgumentException('Please, define your rules for validation.');
        }
        $this->cleanupParameters();

        $this->builder = $builder;
        $this->builder->declareClasses(
            'Symfony\\Component\\Validator\\Mapping\\ClassMetadata',
            'Symfony\\Component\\Validator\\DefaultTranslator',
            'Symfony\\Component\\Validator\\Mapping\\Loader\\StaticMethodLoader',
            'Symfony\\Component\\Validator\\ConstraintValidatorFactory',
            'Symfony\\Component\\Validator\\ConstraintViolationList'
        );

        //if SF >= 2.5 use new validator classes
        if(class_exists('Symfony\\Component\\Validator\\Validator\\RecursiveValidator')) {
            $this->builder->declareClasses(
                'Symfony\\Component\\Validator\\Validator\\RecursiveValidator',
                'Symfony\\Component\\Validator\\Context\\ExecutionContextFactory',
                'Symfony\\Component\\Validator\\Mapping\\Factory\LazyLoadingMetadataFactory',
                'Symfony\\Component\\Validator\\Context\\ExecutionContextInterface',
                'Symfony\\Component\\Validator\\Validator\\ValidatorInterface',
                //'Symfony\\Component\\Translation\\IdentityTranslator'
{'fraction_non_alphanumeric': 0.11832148589772988, 'fraction_numerical': 0.001375831231368952, 'mean_word_length': 2.712340425531915, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, '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': '2140510', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1033, 'n_words': 225}