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

namespace Fresh\DoctrineEnumBundle\Validator\Constraints;

use Symfony\Component\Validator\Constraints\Choice;

/**
 * ENUM Constraint
 *
 * @author <NAME> <<EMAIL>>
 *
 * @Annotation
 */
class Enum extends Choice
{
    /**
     * @var string $entity Entity
     */
    public $entity;

    /**
     * {@inheritdoc}
     */
    public function getRequiredOptions()
    {
        return ['entity'];
    }

    /**
     * {@inheritdoc}
     */
    public function getDefaultOption()
    {
        return 'choices';
    }
}<commit_msg>Update Enum class. Load choices from entity.<commit_after><?php
/*
 * This file is part of the FreshDoctrineEnumBundle
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Fresh\DoctrineEnumBundle\Validator\Constraints;

use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
use Symfony\Component\Validator\Constraints\Choice;

/**
 * ENUM Constraint
 *
 * @author <NAME> <<EMAIL>>
 *
 * @Annotation
 */
class Enum extends Choice
{
    /**
     * @var string $entity Entity
     */
    public $entity;

    /**
     * {@inheritdoc}
     */
    public function __construct($options = null)
    {
        /** @var AbstractEnumType $entity */
        $entity = $options['entity'];
        $this->choices = array_keys($entity::getChoices());

        parent::__construct($options);
    }

    /**
     * {@inheritdoc}
     */
    public function getRequiredOptions()
    {
        return ['entity'];
    }

    /**
     * {@inheritdoc}
     */
    public function getDefaultOption()
    {
        return 'choices';
    }
}
{'fraction_non_alphanumeric': 0.13134484563055993, 'fraction_numerical': 0.0, 'mean_word_length': 2.614366729678639, 'pattern_counts': {'":': 0, '<': 17, '<?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': '2620939', 'n_tokens_mistral': 555, 'n_tokens_neox': 548, 'n_words': 145}