fromPg

@see ConverterInterface
327164
public function fromPg($data, $type, Session $session)
    {
        $data = trim($data);

        return
            $data !== ''
            ? $this->createObjectFrom($data)
            : null
            ;
    }
1072298
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
    {
        if ($source instanceof \DateTimeInterface) {
            return $source->format('U');
        }

        if ($source === null || strlen($source) === 0) {
            return null;
        }

        if (!is_numeric($source)) {
            return new Error('"%s" is not numeric.', 1332933658, [$source]);
        }
        return (integer)$source;
    }
506637
function it_converts_and_normalizes_nested_sets_to_pg($normalizer, $converter)
    {
        $this->setType('decimal', $converter, $normalizer);

        $this
            ->toPg(
                [
                    [
                        (object) [
                            'value' => 3.14159265359
                        ]
                    ],
                    [
                        (object) [
                            'value' => 1.66180339887
                        ]
                    ]
                ],
                'decimal[][]'
            )
            ->shouldBeLike(new Set(
                [
                    new Set(
                        [
                            new Value('3.14159265359', new Type('decimal'))
                        ],
                        new ArrayType(new Type('decimal'))
                    ),
                    new Set(
                        [
                            new Value('1.66180339887', new Type('decimal'))
                        ],
                        new ArrayType(new Type('decimal'))
                    )
                ],
                new ArrayType(new ArrayType(new Type('decimal')))
            ))
        ;
    }
1120410
static public function convert($uuid, $from, $to) {
    $conv = self::$m_convert[$from][$to];
    if (!isset($conv))
      return ($uuid);

    return (self::$conv($uuid));
  }
836122
@Override
  public final String fromString(final Map<String, Object> pAddParam,
    final String pStrVal) throws Exception {
    if (pStrVal == null || "".equals(pStrVal)) {
      return null;
    }
    return pStrVal;
  }
563955
private function convertCompositeToPg($data, TypeInterface $type)
    {
        $mapping = $this->getMapping($type);

        if ($normalizer = $this->getNormalizer($type)) {
            $data = $normalizer->toPg($data, [
                'mapping' => $mapping,
            ]);
        }

        $fragments = [];

        foreach ($mapping as $field => $fieldType) {
            if (!isset($data[$field])) {
                $fragments[$field] = $fieldType instanceof ArrayType ? new Set([], $fieldType) : new Value('null');

                continue;
            }

            $fragments[$field] = $this->toPg($data[$field], $fieldType);
        }

        return new Row($fragments, $type);
    }
1208889
public static function convert_from($data, $charset = 'cp1251')
	{
		if (! ReflectionTypeHint::isValid()) return false;
		return self::_convert($data, $charset, 'UTF-8');
	}
154402
protected static function _convertCharset($input, $from, $to)
    {
        /* Use utf8_[en|de]code() if possible and if the string isn't too
         * large (less than 16 MB = 16 * 1024 * 1024 = 16777216 bytes) - these
         * functions use more memory. */
        if (Horde_Util::extensionExists('xml') &&
            ((strlen($input) < 16777216) ||
             !Horde_Util::extensionExists('iconv') ||
             !Horde_Util::extensionExists('mbstring'))) {
            if (($to == 'utf-8') &&
                in_array($from, array('iso-8859-1', 'us-ascii', 'utf-8'))) {
                return utf8_encode($input);
            }

            if (($from == 'utf-8') &&
                in_array($to, array('iso-8859-1', 'us-ascii', 'utf-8'))) {
                return utf8_decode($input);
            }
        }

        /* Try UTF7-IMAP conversions. */
        if (($from == 'utf7-imap') || ($to == 'utf7-imap')) {
            try {
                if ($from == 'utf7-imap') {
                    return self::convertCharset(Horde_Imap_Client_Utf7imap::Utf7ImapToUtf8($input), 'UTF-8', $to);
                } else {
                    if ($from == 'utf-8') {
                        $conv = $input;
                    } else {
                        $conv = self::convertCharset($input, $from, 'UTF-8');
                    }
                    return Horde_Imap_Client_Utf7imap::Utf8ToUtf7Imap($conv);
                }
            } catch (Horde_Imap_Client_Exception $e) {
                return $input;
            }
        }

        /* Try iconv with transliteration. */
        if (Horde_Util::extensionExists('iconv')) {
            unset($php_errormsg);
            ini_set('track_errors', 1);
            $out = @iconv($from, $to . '//TRANSLIT', $input);
            $errmsg = isset($php_errormsg);
            ini_restore('track_errors');
            if (!$errmsg && $out !== false) {
                return $out;
            }
        }

        /* Try mbstring. */
        if (Horde_Util::extensionExists('mbstring')) {
            $out = @mb_convert_encoding($input, $to, self::_mbstringCharset($from));
            if (!empty($out)) {
                return $out;
            }
        }

        return $input;
    }
831413
private function readSpgrContainer()
    {
        // context is either context DgContainer or SpgrContainer

        $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
        $recordData = substr($this->data, $this->pos + 8, $length);

        // move stream pointer to next record
        $this->pos += 8 + $length;

        // record is a container, read contents
        $spgrContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer();

        if ($this->object instanceof PHPExcel_Shared_Escher_DgContainer) {
            // DgContainer
            $this->object->setSpgrContainer($spgrContainer);
        } else {
            // SpgrContainer
            $this->object->addChild($spgrContainer);
        }

        $reader = new PHPExcel_Reader_Excel5_Escher($spgrContainer);
        $escher = $reader->load($recordData);
    }
330790
public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        if (empty($value)) {
            return null;
        }

        if ($value instanceof UuidInterface) {
            return $value;
        }

        try {
            return $this->decode($value);
        } catch (InvalidArgumentException $e) {
            throw ConversionException::conversionFailed($value, self::NAME);
        }
    }
1215454
protected static function convertBase(
        /*# string */ $input,
        /*# string */ $fromBase,
        /*# string */ $toBase
    )/*# : string */ {
        if ($fromBase === $toBase) {
            return $input;
        } elseif ($fromBase === self::BASE10) {
            return static::fromBase10($input, $toBase);
        } elseif ($toBase === self::BASE10) {
            return static::toBase10($input, $fromBase);
        } else {
            return static::fromBase10(static::toBase10($input, $fromBase), $toBase);
        }
    }
461917
@Override
  public final Double fromString(final Map<String, Object> pAddParam,
    final String pStrVal) throws Exception {
    if (pStrVal == null || "".equals(pStrVal)) {
      return null;
    }
    if (pAddParam != null) {
      String dsep = (String) pAddParam.get("decSepv");
      if (dsep != null) {
        String dgsep = (String) pAddParam.get("decGrSepv");
        String strVal = pStrVal.replace(dgsep, "").replace(dsep, ".");
        return Double.valueOf(strVal);
      }
    }
    return Double.valueOf(pStrVal);
  }
1021516
public function convert()
    {
        if (count($this->arrayBlocks) <= 0) {
            return null;
        }
        try {
            $this->blockRepository->startTransaction();
            $result = $this->deleteBlocks();
            if (false !== $result) {
                $languages = $this->languageRepository->activeLanguages();
                foreach ($this->arrayBlocks as $block) {
                    foreach ($languages as $language) {
                        $result = $this->updateBlock($block, $language->getId(), 1);
                    }
                }

                if ($result) {
                    $this->blockRepository->commit();
                } else {
                    $this->blockRepository->rollBack();
                }
            }

            return $result;
        } catch (\Exception $e) {
            if (isset($this->blockRepository) && $this->blockRepository !== null) {
                $this->blockRepository->rollBack();
            }

            throw $e;
        }
    }
580629
private function convertArrayFromPg($data, ArrayType $type)
    {
        $array = [];

        // This trick handle the case where two table are joined together and the right side hasn't any matching rows
        // with the left side. Using the array_agg aggregate on such a join will produces an array with one null value
        // inside.
        if ($data === [null]) {
            return $array;
        }

        foreach ($data as $row) {
            $array[] = $this->fromPg($row, $type->getSubType());
        }

        return $array;
    }
1120158
protected function convertField($name, $value)
    {
        return $this
            ->converters[$name]
            ->fromPg($value, $this->types[$name])
            ;
    }
526639
public function checkConvertability()
    {
        $im = new \Gmagick();
        $mimeType = $this->getMimeTypeOfSource();
        switch ($mimeType) {
            case 'image/png':
                if (!in_array('PNG', $im->queryFormats())) {
                    throw new SystemRequirementsNotMetException(
                        'Imagick has been compiled without PNG support and can therefore not convert this PNG image.'
                    );
                }
                break;
            case 'image/jpeg':
                if (!in_array('JPEG', $im->queryFormats())) {
                    throw new SystemRequirementsNotMetException(
                        'Imagick has been compiled without Jpeg support and can therefore not convert this Jpeg image.'
                    );
                }
                break;
        }
    }
945994
public function convert($fromTime, $toTime = null)
    {
        $interval = $this->getInterval($fromTime, $toTime);
        $units = $this->calculateUnits($interval);

        return $this->translation->translate($units, $interval->invert);
    }