@param mixed $value

@throws \Symfony\Component\Form\Exception\TransformationFailedException
@return string
335989
public function transform($value)
    {
        if (null === $value) {
            return '';
        } elseif ($value instanceof Collection) {
            $values = $value->toArray();
        } elseif (is_array($value)) {
            $values = $value;
        } else {
            throw new TransformationFailedException('TagTransformer expects to transform an array or Collection value');
        }

        $propertyAccessor = $this->propertyAccessor;
        $property = $this->property;
        $values = array_map(function ($value) use ($propertyAccessor, $property) {
            return $propertyAccessor->getValue($value, $property);
        }, $values);

        return implode(',', $values);
    }
1044161
public function reverseTransform($value)
    {
        if (null === $value) {
            return;
        }

        if (!\is_array($value)) {
            throw new TransformationFailedException('Expected an array.');
        }

        if ('' === implode('', $value)) {
            return;
        }

        $emptyFields = [];

        foreach ($this->fields as $field) {
            if (!isset($value[$field])) {
                $emptyFields[] = $field;
            }
        }

        if (\count($emptyFields) > 0) {
            throw new TransformationFailedException(sprintf('The fields "%s" should not be empty', implode('", "', $emptyFields)));
        }

        if (isset($value['month']) && !ctype_digit((string) $value['month'])) {
            throw new TransformationFailedException('This month is invalid');
        }

        if (isset($value['day']) && !ctype_digit((string) $value['day'])) {
            throw new TransformationFailedException('This day is invalid');
        }

        if (isset($value['year']) && !ctype_digit((string) $value['year'])) {
            throw new TransformationFailedException('This year is invalid');
        }

        if (!empty($value['month']) && !empty($value['day']) && !empty($value['year']) && false === checkdate($value['month'], $value['day'], $value['year'])) {
            throw new TransformationFailedException('This is an invalid date');
        }

        if (isset($value['hour']) && !ctype_digit((string) $value['hour'])) {
            throw new TransformationFailedException('This hour is invalid');
        }

        if (isset($value['minute']) && !ctype_digit((string) $value['minute'])) {
            throw new TransformationFailedException('This minute is invalid');
        }

        if (isset($value['second']) && !ctype_digit((string) $value['second'])) {
            throw new TransformationFailedException('This second is invalid');
        }

        try {
            $dateTime = new \DateTime(sprintf(
                '%s-%s-%s %s:%s:%s',
                empty($value['year']) ? '1970' : $value['year'],
                empty($value['month']) ? '1' : $value['month'],
                empty($value['day']) ? '1' : $value['day'],
                empty($value['hour']) ? '0' : $value['hour'],
                empty($value['minute']) ? '0' : $value['minute'],
                empty($value['second']) ? '0' : $value['second']
                ),
                new \DateTimeZone($this->outputTimezone)
            );

            if ($this->inputTimezone !== $this->outputTimezone) {
                $dateTime->setTimezone(new \DateTimeZone($this->inputTimezone));
            }
        } catch (\Exception $e) {
            throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
        }

        return $dateTime;
    }
1155617
public function serialize($value): string
    {
        if ($value instanceof Carbon) {
            return $value->toDateString();
        }

        return $this->tryParsingDate($value, InvariantViolation::class)
            ->toDateString();
    }
1004528
public function transform($value)
    {
        try {
            return array(
                'id' => (null !== $value ? $value->getId() : null),
                'value' => (null !== $value ? $value->__toString() : null)
            );
        } catch (EntityNotFoundException $e) {
            return ['id' => null, 'value' => '-- ENTITY NOT FOUND --'];
        }
    }
737911
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

        if (!$value instanceof User) {
            throw new TransformationFailedException('Expected a ' . User::class . ' object.');
        }

        return $value->id;
    }
195788
public function reverseTransform($value)
    {
        return null !== $value && !empty($value)
            ? $this->contentTypeService->loadContentTypeByIdentifier($value)
            : null;
    }
161757
public function transform($value)
    {
        if (function_exists('mb_check_encoding')) {
            $isUtf8 = mb_check_encoding($value, 'UTF-8');
        } else {
            $isUtf8 = $this->checkUtf8Encoding($value);
        }

        return  $isUtf8 ? $value : utf8_encode($value);
    }
206628
protected function formatValue($value)
    {
        if (PHP_VERSION_ID < 50400) {
            return str_replace('\/', '/', json_encode($value));
        }

        return json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
    }
845990
public function serialize($value) : string
    {
        if (!$value instanceof \DateTimeInterface) {
            throw InvalidValueException::valueDoesNotMatchType($this, $value);
        }

        return (string) $value->format($this->format);
    }
434036
public function reverseTransform($value)
    {
        if (!$value) {
            return null;
        }

        if (!is_string($value)) {
            throw new TransformationFailedException('Expected a string.');
        }

        if (!$value || !$this->parseUrl($value)) {
            throw new TransformationFailedException('Empty or invalid string.');
        }

        $video = $this->videoManager->findByVideoId($this->videoId);

        if (!$video) {
            $video = $this->videoManager->createVideo();

            $video->setVideoId($this->videoId);
            $video->setType($this->videoType);
            $video->setUrl($value);
        }

        return $video;
    }
171929
private static function transformValue($value)
    {
        if (is_null($value)) {
            return $value;
        }

        if ($value instanceof PrimalValued) {
            $value = $value->toPrimitive();
        } elseif ($value instanceof Arrayable) {
            $value = $value->toArray();
            if (empty($value)) {
                $value = null;
            }
        } elseif (is_array($value)) {
            $value = array_map(function ($arrValue) {
                return self::transformValue($arrValue);
            }, $value);
        } elseif ($value instanceof \DateTimeZone) {
            $value = $value->getName();
        } elseif ($value instanceof Carbon) {
            $value = $value->toRfc3339String();
        }

        return $value;
    }
881112
public function serialize($value): string
    {
        $id = $this->entityManager->getClassMetadata($this->className)->getIdentifierValues($value);

        return (string) reset($id);
    }
918810
public function reverseTransform($value): ?MoneyValue
    {
        if (null === $value || '' === $value) {
            return null;
        }

        if (!\is_string($value)) {
            throw new TransformationFailedException('Expected a string or null.');
        }

        if ('NaN' === $value) {
            throw new TransformationFailedException('"NaN" is not a valid number');
        }

        if (false !== mb_strpos($value, '∞')) {
            throw new TransformationFailedException('I don\'t have a clear idea what infinity looks like.');
        }

        // Convert normal spaces to fixed spaces.
        $value = str_replace(' ', "\xc2\xa0", $value);

        $formatter = $this->getNumberFormatter();

        $groupSep = $formatter->getSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL);
        $decSep = $formatter->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
        $withCurrency = (bool) preg_match('#\p{Sc}#u', $value);

        // Some locales use the space as group separation.
        // The ICU data confirms this, but since v58.1 this can no longer be parsed
        // in the currency format. Unless you use DECIMAL which doesn't work
        // for currency. So... simple remove the spaces between numbers.
        $value = preg_replace("/(\\p{N})\xc2\xa0(\\p{N})/u", '$1$2', $value);

        if ('.' !== $decSep && (!$this->grouping || '.' !== $groupSep)) {
            $value = str_replace('.', $decSep, $value);
        }

        if (',' !== $decSep && (!$this->grouping || ',' !== $groupSep)) {
            $value = str_replace(',', $decSep, $value);
        }

        if (!$withCurrency) {
            $value = $this->addCurrencySymbol($value);
        }

        try {
            $money = (new IntlMoneyParser($formatter, new ISOCurrencies()))->parse($value);

            return new MoneyValue($money, $withCurrency);
        } catch (ParserException $e) {
            throw new TransformationFailedException($e->getMessage(), 0, $e);
        } catch (\Exception $e) {
            throw new TransformationFailedException($e->getMessage(), 0, $e);
        }
    }
1126176
public function transform($value)
    {
        if ($value === null || $value == '') {
            return null;
        }
        if (!($value instanceof File)) {
            throw new TransformationFailedException('Expected an instance of a concrete5 file object.');
        }
        return intval($value->getFileID());
    }
27905
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

        if (!is_bool($value)) {
            throw new TransformationFailedException('Expected a boolean.');
        }

        return $value ? $this->trueValue : $this->falseValue;
    }
1228025
public function reverseTransform($value)
    {
        if (null === $value) {
            return null;
        }

        $repo = $this->em->getRepository($this->className);
        $entity = $repo->find($value);

        if (!$entity) {
            return null;
        }

        return $entity;
    }
573441
public function reverseTransform($value): ?APILocation
    {
        if (empty($value)) {
            return null;
        }

        try {
            return $this->locationService->loadLocation($value);
        } catch (NotFoundException $e) {
            throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
        }
    }