<commit_before><?php

namespace OpenOrchestra\ModelBundle\Validator\Constraints;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;

/**
 * Class UniqueFieldIdContentTypeValidator
 */
class UniqueFieldIdContentTypeValidator extends ConstraintValidator
{

    /**
     * @param mixed $value
     * @param Constraint $constraint
     */
    public function validate($value, Constraint $constraint)
    {
        $fields = $value->getFields();
        $fieldsId = array();

        foreach ($fields as $field) {
            $fieldId = $field->getFieldId();
            if (in_array($fieldId, $fieldsId)){
                $this->context->buildViolation($constraint->message)
                              ->addViolation();
            }
            $fieldsId[] = $fieldId;
        }
    }
}<commit_msg>add type of parameter and add violation to fields attribute<commit_after><?php

namespace OpenOrchestra\ModelBundle\Validator\Constraints;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use OpenOrchestra\ModelInterface\Model\ContentTypeInterface;

/**
 * Class UniqueFieldIdContentTypeValidator
 */
class UniqueFieldIdContentTypeValidator extends ConstraintValidator
{
    /**
     * @param ContentTypeInterface                $value
     * @param UniqueFieldIdContentType|Constraint $constraint
     */
    public function validate($value, Constraint $constraint)
    {
        $fields = $value->getFields();
        $fieldsId = array();

        foreach ($fields as $field) {
            $fieldId = $field->getFieldId();
            if (in_array($fieldId, $fieldsId)){
                $this->context->buildViolation($constraint->message)
                              ->atPath("fields")
                              ->addViolation();
            }
            $fieldsId[] = $fieldId;
        }
    }
}
{'fraction_non_alphanumeric': 0.11105263157894738, 'fraction_numerical': 0.0, 'mean_word_length': 2.5009208103130756, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, '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': '6001393', 'n_tokens_mistral': 485, 'n_tokens_neox': 481, 'n_words': 94}