src/Bridge/Symfony/Form/DataTransformer/ValueToEnumTransformer.php
public function transform($value)
    {
        if ($value === null) {
            return null;
        }

        if (!$value instanceof $this->enumClass) {
            throw new TransformationFailedException(sprintf(
                'Expected instance of "%s". Got "%s".',
                $this->enumClass,
                \is_object($value) ? \get_class($value) : \gettype($value)
            ));
        }

        return $value->getValue();
    }
public function transform($value)
    {
        if ($value === null) {
            return null;
        }

        if (!$value instanceof $this->enumClass) {
            throw new TransformationFailedException(sprintf(
                'Expected instance of "%s". Got "%s".',
                $this->enumClass,
                \is_object($value) ? \get_class($value) : \gettype($value)
            ));
        }

        return $value->getValue();
    }
public function transform ( $ value ) { if ( $ value === null ) { return null ; } if ( ! $ value instanceof $ this -> enumClass ) { throw new TransformationFailedException ( sprintf ( 'Expected instance of "%s". Got "%s".' , $ this -> enumClass , \ is_object ( $ value ) ? \ get_class ( $ value ) : \ gettype ( $ value ) ) ) ; } return $ value -> getValue ( ) ; }
Transforms EnumInterface object to a raw enumerated value.

@param EnumInterface|null $value EnumInterface instance

@throws TransformationFailedException When the transformation fails

@return int|string|null Value of EnumInterface
Transforms EnumInterface object to a raw enumerated value .