Convierte unidades

@param $type Tipo de unidad
@param $qty Cantidad a convertir
@param $fromUnit Unidad de origen
@param $toUnit Unidad de destino

@return Resultado o falso (si hay error)
486516
public function convert($type, $qty, $fromUnit, $toUnit,$decimal=18) {
        $this->validUnitType($type);
        return $this->formatResult($this->unitTypes[$type]->convert($qty, $fromUnit, $toUnit), $decimal);
    }
1120410
static public function convert($uuid, $from, $to) {
    $conv = self::$m_convert[$from][$to];
    if (!isset($conv))
      return ($uuid);

    return (self::$conv($uuid));
  }
679423
public static function auto_charset($fContents, $from, $to)
    {
        $from = strtoupper($from) == 'UTF8' ? 'utf-8' : $from;
        $to   = strtoupper($to) == 'UTF8' ? 'utf-8' : $to;
        if (strtoupper($from) === strtoupper($to) || empty($fContents) || (is_scalar($fContents) && !is_string($fContents))) {
            // 如果编码相同或者非字符串标量则不转换
            return $fContents;
        }

        if (is_string($fContents)) {
            if (function_exists('mb_convert_encoding')) {
                return mb_convert_encoding($fContents, $to, $from);
            } elseif (function_exists('iconv')) {
                return iconv($from, $to, $fContents);
            } else {
                return $fContents;
            }

        } elseif (is_array($fContents)) {
            foreach ($fContents as $key => $val) {
                $_key             = self::auto_charset($key, $from, $to);
                $fContents[$_key] = self::auto_charset($val, $from, $to);
                if ($key != $_key) {
                    unset($fContents[$key]);
                }
            }
            return $fContents;
        } else {
            return $fContents;
        }
    }
418693
public static function skills($qty = 1, $max = 0)
    {
        if ($max > 0) {
            $qty = self::numberBetween($qty, $max);
        }

        return self::randomElements(self::$skills, $qty);
    }
1150582
public function getUnits($type = null)
    {
        if (!isset($type)) {
            return $this->units;
        }

        $filtered = array();
        foreach ($this->units as $key => $value) {
            if (isset($value['type']) && $value['type'] === $type) {
                $filtered[$key] = $value;
            }
        }

        return $filtered;
    }
1303678
@SuppressWarnings("unchecked")
    public static <T> T convert(Object fromValue, Class<T> toType) throws TypeCastException {
        return convert(fromValue, toType, (String) null);
    }
1139401
public function relativeDateFilter($field, $fromUnit = self::RELATIVE_DATE_FILTER_UNIT_MINUTES, $fromInterval, $toUnit = self::RELATIVE_DATE_FILTER_UNIT_MINUTES, $toInterval = 0, $dateFormat = self::RELATIVE_DATE_FILTER_DATEFORMAT, $isNegative = false) {
		$parameters = array(
	        'fromUnit' => $fromUnit,
	        'fromInterval' => $fromInterval,
	        'toUnit' => $toUnit,
		    'toInterval' => $toInterval,
		    'dateFormat' => $dateFormat,
		    'field' => $field
	    );
	    $this->addFilter(null, self::RELATIVE_DATE_FILTER, $isNegative, $parameters);
		return $this;
	}
980839
public function replaceUser(User $from, User $to)
    {
        $contributions = $this->contributionRepository->findByContributor($from);

        if (count($contributions) > 0) {
            foreach ($contributions as $contribution) {
                $contribution->setContributor($to);
            }

            $this->om->flush();
        }

        return count($contributions);
    }
1198504
public function setToType($to_type)
    {
        if ($to_type == $this->to_type) return $this;
        $to_type = strtoupper($to_type);
        if (!isset(self::getAddressTypes()[$to_type])) {
            throw new \InvalidArgumentException(sprintf('The "%s" to_type is not a valid address type.', $to_type));
        }
        $this->to_type = $to_type;
        return $this;
    }
253806
public function encode($toEncodingFormat = null, $fromEncodingFormat = null)
    {
        return $this->addRule(new FilterRule\Encode($toEncodingFormat, $fromEncodingFormat));
    }
650573
static function upload($from, $to)
    {
        $result = false;
        if(is_uploaded_file($from)){
            $to = self::makeVirtualDir($to);
            // Если папки нет, то создаем её
            $dir = dirname($to);
            if(!is_dir($dir)){
                mkdir($dir, 0775, true);
            }
            if (is_file($to)){
                unlink($to);
            }
            //Перемещаем файл если он загружен через POST
            $result = move_uploaded_file($from, $to);
            self::deleteVirtualDir($to);
        }
        return $result;
    }
1172624
public function sendPresence($to, $from = NULL, $type = NULL) {
		$type = is_null($type) ? '' : " type=\"{$type}\"";
		return $this->send('<presence to="' . htmlspecialchars($to) . '" from="' . (is_null($from) ? $this->component_name : htmlspecialchars("$from@{$this->component_name}")) . '"' . $type . ' />');
	}
310765
public static function convert($no, $fromBase, $toBase) {
        if ($fromBase == $toBase) {
            return $no;
        }

        return base_convert($no, $fromBase, $toBase);
    }
90316
public function determineActions(Type $fromType, Type $toType)
    {
        $actions = array();
        foreach ($fromType->fieldDefinitions as $fieldDef) {
            if (!$this->hasFieldDefinition($toType, $fieldDef)) {
                $actions[] = new ContentUpdater\Action\RemoveField(
                    $this->contentGateway,
                    $fieldDef,
                    $this->storageHandler,
                    $this->contentMapper
                );
            }
        }
        foreach ($toType->fieldDefinitions as $fieldDef) {
            if (!$this->hasFieldDefinition($fromType, $fieldDef)) {
                $actions[] = new ContentUpdater\Action\AddField(
                    $this->contentGateway,
                    $fieldDef,
                    $this->converterRegistry->getConverter(
                        $fieldDef->fieldType
                    ),
                    $this->storageHandler,
                    $this->contentMapper
                );
            }
        }

        return $actions;
    }
301074
private void init(final long qty, final TimeUnit unit) {
        long millis = unit.convert(qty);
        seconds = TimeUnit.MILLISECOND.convert(millis, TimeUnit.SECOND) % 60;
        minutes = TimeUnit.MILLISECOND.convert(millis, TimeUnit.MINUTE) % 60;
        hours = TimeUnit.MILLISECOND.convert(millis, TimeUnit.HOUR) % 24;
        days = TimeUnit.MILLISECOND.convert(millis, TimeUnit.DAY);
    }
1196615
public static function encodeConvert($data, $from = 'gbk', $to = 'utf-8')
    {
        if (is_array($data)) {
            array_walk_recursive($data, function (&$data, $key) use ($from, $to) {
                $data = mb_convert_encoding($data, $to, $from);
            });
        } elseif (is_object($data)) {
            array_walk_recursive($data, function (&$data, $key) use ($from, $to) {
                $data = mb_convert_encoding($data, $to, $from);
            }, array('utf-8', 'gbk'));
        } else {
            $data = mb_convert_encoding($data, $to, $from);
        }

        return $data;
    }
1355350
public function setFromType($from_type)
    {
        if ($from_type == $this->from_type) return $this;
        $from_type = strtoupper($from_type);
        if (!isset(self::getAddressTypes()[$from_type])) {
            throw new \InvalidArgumentException(sprintf('The "%s" from_type is not a valid address type.', $from_type));
        }

        $this->from_type = $from_type;
        return $this;
    }