for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the FreshDoctrineEnumBundle.
*
* (c) Artem Henvald <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Fresh\DoctrineEnumBundle\Validator\Constraints;
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
use Symfony\Component\Validator\Constraints\Choice;
/**
* ENUM Constraint.
* @author Artem Henvald <[email protected]>
* @Annotation
class Enum extends Choice
{
/** @var string|AbstractEnumType */
public $entity;
* {@inheritdoc}
public function __construct($options = null)
$this->strict = true;
if (isset($options['entity'])) {
/** @var AbstractEnumType $entity */
$entity = $options['entity'];
if (\is_subclass_of($entity, AbstractEnumType::class)) {
is_subclass_of
\Fresh\DoctrineEnumBundl...AbstractEnumType::class
ReflectionClass::implementsInterface
$this->choices = $entity::getValues();
}
parent::__construct($options);
* @return string[]
public function getRequiredOptions(): array
return ['entity'];