@inheritdoc

@throws ConversionException
422668
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        return parent::convertToDatabaseValue(
            $this->convertToDateTimeFromString($value, $platform->getDateTimeFormatString(), static::NAME),
            $platform
        );
    }
884098
public function convertToPHPValue($value, PlatformInterface $platform)
    {
        if ($value === null) {
            return;
        }

        $phpValue = \DateTime::createFromFormat('!'.$platform->getDateFormat(), $value);

        if ($phpValue === false) {
            throw TypeException::conversionToPHPFailed($value, $this->getName());
        }

        return $phpValue;
    }
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;
    }
313644
public function convert($currency)
    {
        if ($this->isAvailable($currency)) {
            $rate = 1 / $this->rates[$currency];
            return round($this->base * $rate, 2);
        } else {
            throw new RuntimeException(sprintf(
                'Target currency "%s" does not belong to the registered map of rates', $currency
            ));
        }
    }
1245702
public function convert() {

        $resource = $file = \tao_helpers_Http::getUploadedFile('content');

        $base64Converter = new Base64ConverterModel($resource);

        $this -> returnJson($base64Converter->convertToBase64());
    }
243132
public function convertToPHPValue($value, PlatformInterface $platform)
    {
        if ($value === null) {
            return;
        }

        $val = @unserialize($value);

        if ($val === false) {
            throw TypeException::conversionToPHPFailed($value, $this->getName());
        }

        return $val;
    }
840194
public function convert($scopeId, $scope)
    {
        if (is_numeric($scopeId)) {
            return $scopeId;
        }

        $entities = $this->getEntityStore($scope);
        if (isset($entities[$scopeId])) {
            return $entities[$scopeId]->getId();
        }

        throw new ScopeConvertException(sprintf('Unable to process code "%s" for scope "%s"', $scopeId, $scope));
    }
489747
public function doConvert()
    {
        $beginTime = microtime(true);

        $this->activateWarningLogger();
        //set_error_handler(array($this, "errorHandler"));

        try {
            // Prepare options
            //$this->prepareOptions();

            $this->checkOptions();

            // Prepare destination folder
            $this->createWritableDestinationFolder();
            $this->removeExistingDestinationIfExists();

            if (!isset($this->options['_skip_input_check'])) {
                // Run basic input validations (if source exists and if file extension is valid)
                $this->checkInput();

                // Check that a file can be written to destination
                $this->checkFileSystem();
            }

            $this->checkOperationality();
            $this->checkConvertability();
            $this->runActualConvert();
        } catch (ConversionFailedException $e) {
            $this->deactivateWarningLogger();
            throw $e;
        } catch (\Exception $e) {
            $this->deactivateWarningLogger();
            throw new UnhandledException('Conversion failed due to uncaught exception', 0, $e);
        } catch (\Error $e) {
            $this->deactivateWarningLogger();
            // https://stackoverflow.com/questions/7116995/is-it-possible-in-php-to-prevent-fatal-error-call-to-undefined-function
            //throw new UnhandledException('Conversion failed due to uncaught error', 0, $e);
            throw $e;
        }
        $this->deactivateWarningLogger();

        $source = $this->source;
        $destination = $this->destination;

        if (!@file_exists($destination)) {
            throw new ConversionFailedException('Destination file is not there: ' . $destination);
        } elseif (@filesize($destination) === 0) {
            unlink($destination);
            throw new ConversionFailedException('Destination file was completely empty');
        } else {
            if (!isset($this->options['_suppress_success_message'])) {
                $this->ln();
                $msg = 'Converted image in ' .
                    round((microtime(true) - $beginTime) * 1000) . ' ms';

                $sourceSize = @filesize($source);
                if ($sourceSize !== false) {
                    $msg .= ', reducing file size with ' .
                        round((filesize($source) - filesize($destination))/filesize($source) * 100) . '% ';

                    if ($sourceSize < 10000) {
                        $msg .= '(went from ' . round(filesize($source)) . ' bytes to ';
                        $msg .= round(filesize($destination)) . ' bytes)';
                    } else {
                        $msg .= '(went from ' . round(filesize($source)/1024) . ' kb to ';
                        $msg .= round(filesize($destination)/1024) . ' kb)';
                    }
                }
                $this->logLn($msg);
            }
        }
    }
524647
public static function convertEntities($value)
    {
        $converted = null;
        
        //deal with double encoded payload 
        $value = preg_replace('/&amp;/', '&', $value);     
        
        if (preg_match('/&#x?[\w]+/ms', $value)) {
            $converted = preg_replace('/(&#x?[\w]{2}\d?);?/ms', '$1;', $value);
            $converted = html_entity_decode($converted, ENT_QUOTES, 'UTF-8');
            $value    .= "\n" . str_replace(';;', ';', $converted);
        }
        // normalize obfuscated protocol handlers
        $value = preg_replace(
            '/(?:j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t\s*:)|(d\s*a\s*t\s*a\s*:)/ms', 
            'javascript:', $value
        );
        
        return $value;
    }
105502
private function getConversionMap()
    {
        $conversion_maps = array(
            $this->speed_conversion_map,
            $this->distance_conversion_map,
            $this->pressure_conversion_map,
        );

        foreach ($conversion_maps as $map) {
            if (array_key_exists($this->unit, $map)) {
                return $map;
            }
        }

        throw new \Exception('Trying to convert unsupported values');
    }
1154003
public function validate()
    {
        if (!$this->translatable) {
            throw new MappingException(sprintf('No translatable specified for %s', $this->name));
        }

        if (!$this->targetEntity) {
            throw new MappingException(sprintf('No translatable targetEntity specified for %s', $this->name));
        }

        if (!$this->locale) {
            throw new MappingException(sprintf('No locale specified for %s', $this->name));
        }
    }
746724
public function conversion(float $value = null, string $currency = null, int $transactionId = null): void
	{
		if ($this->config->adWordsConversionId) {
			$data = new ArrayHash;
			$data->value = $value;
			$data->currency = $currency;
			$data->transaction_id = $transactionId ?? '';

			$this->event('conversion',
				'AW-' . $this->config->adWordsConversionId . '/' . $this->config->adWordsConversionLabel,
				$data);
		}
	}
943897
public function convert() {
        //Verify the record exists before proceeding
        if(empty($this->record) || $this->record===false || !$this->record->exists()) {
            return $this->httpError(404, _t('KapostAdmin.KAPOST_CONTENT_NOT_FOUND', '_Incoming Kapost Content could not be found'));
        }
        
        return $this->customise(array(
                                    'Title'=>_t('KapostAdmin.CONVERT_OBJECT', '_Convert Object'),
                                    'Content'=>null,
                                    'Form'=>$this->ConvertObjectForm(),
                                    'KapostObject'=>$this->record
                                ))->renderWith('KapostAdmin_ConvertDialog');
    }
1327247
public static function conversionFailedFormat($value, $toType, $expectedFormat, ?Throwable $previous = null)
    {
        $value = strlen($value) > 32 ? substr($value, 0, 20) . '...' : $value;

        return new self(
            'Could not convert database value "' . $value . '" to Doctrine Type ' .
            $toType . '. Expected format: ' . $expectedFormat,
            0,
            $previous
        );
    }
240683
public static function defaultConverter(FileInterface $_file, $_convertTo)
    {
        $subtitleClass = __NAMESPACE__.'\\Format\\'.ucfirst($_convertTo).'File';

        if (!class_exists($subtitleClass)) {
            throw new \InvalidArgumentException(sprintf('Unable to convert to "%s", this format does not exists.', $_convertTo));
        }

        $newSub        = new $subtitleClass();
        $cueClass      = File::getExpectedCueClass($newSub);

        foreach ($_file->getCues() as $cue) {
            $newSub->addCue($cue->getText(), $cueClass::ms2tc($cue->getStartMS()), $cueClass::ms2tc($cue->getStopMS()));
        }

        return $newSub;
    }
1115710
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
    {
        $result = [];
        $array = ('array' === $targetType)
            ? $source
            : $convertedChildProperties;

        foreach ($array as $name => $subProperty) {
            $result[$name] = $subProperty;

            if (is_object($subProperty)
                && in_array(StoreArrayIndexTrait::class, class_uses($subProperty))
            ) {
                /** @var StoreArrayIndexTrait $subProperty */
                $subProperty->setArrayIndex($name);
            }
        }

        return $result;
    }
999848
public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        if (!$value || !is_string($value)) {
            return null;
        }

        $timepoint = self::getParsingClock()->fromString($value, 'Y-m-d H:i:s');

        if (!$timepoint) {
            throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeFormatString());
        }

        return $timepoint;
    }