Converts a price value to minor units
@param array $data
348706
protected function setPrice(array &$data)
    {
        if (!empty($data['price']) && !empty($data['currency'])) {
            $data['price'] = $this->price->amount($data['price'], $data['currency']);
        }
    }
1228517
public function beforeSerialize(array $data)
    {
        foreach ($data as $idx => &$value) {
            if ($value instanceof \DateTime) {
                $value = $value->format('Y-m-d H:i:s');
            }
        }

        return $data;
    }
782378
private function setCoreData(array $data)
    {
        if (isset($data['input_type'])) {
            $this->setInputType($data['input_type']);
        }

        if (isset($data['display_type'])) {
            $this->setDisplayType($data['display_type']);
        }

        if (isset($data['property_type'])) {
            $this->setPropertyType($data['property_type']);
        }

        if (isset($data['output_type'])) {
            $this->setOutputType($data['output_type']);
        }

        if (isset($data['type'])) {
            $this->setType($data['type']);
        }

        return $data;
    }
1113503
public function denormalizeValue(array $data)
    {
        $processed = array();

        foreach ($data as $docId => $content) {
            $cloned = $content;
            $keys = array_keys($cloned);
            $ofType = array_pop($keys);
            $asArray = ('array' === $ofType)? true : false;

            $value = $content[$ofType];

            Assertion::isJsonString($value, 'Invalid json string in registry');

            $processed[$docId] = json_decode($value, $asArray);
        }

        return $processed;
    }
229461
protected function castArrayValuesToSimpleTypes(array $data)
    {
        foreach ($data as $key => $item) {
            if (is_array($item)) {
                $data[$key] = $this->castArrayValuesToSimpleTypes($item);
            } elseif (is_object($item)) {
                $data[$key] = $this->convertObjectToSimpleType($item);
            }
        }

        return $data;
    }
1306757
public function calculate(array &$data)
    {
        $result = array();
        $this->hook->attach('order.calculate.before', $data, $result, $this);

        if (!empty($result)) {
            return (array) $result;
        }

        $components = array();
        $total = $data['cart']['total'];

        $this->calculateComponents($total, $data, $components);
        $this->calculatePriceRules($total, $data, $components);

        $result = array(
            'total' => $total,
            'components' => $components,
            'currency' => $data['cart']['currency'],
            'total_decimal' => $this->price->decimal($total, $data['cart']['currency']),
            'total_formatted' => $this->price->format($total, $data['cart']['currency']),
            'total_formatted_number' => $this->price->format($total, $data['cart']['currency'], true, false),
        );

        $this->hook->attach('order.calculate.after', $data, $result, $this);
        return (array) $result;
    }
885523
protected function _value($data)
    {
        static $compress;

        if (!isset($compress)) {
            $compress = new Horde_Compress_Fast();
        }

        return ($data instanceof MongoBinData)
            ? @unserialize($compress->decompress($data->bin))
            : new MongoBinData(
                $compress->compress(serialize($data)), MongoBinData::BYTE_ARRAY
            );
    }
507812
private function escapeFloatsIfNeeded(array $data)
    {
        if (PHP_VERSION_ID >= 50606) {
            return $data;
        }

        array_walk_recursive(
            $data,
            function (&$value) {
                if (is_float($value) && ctype_digit((string)$value)) {
                    // Due to PHP bug #50224, floats with no decimals are converted to integers when encoded
                    $value = '(' . self::FLOAT_CASTER . ')' . $value . '.0';
                }
            }
        );

        return $data;
    }
556609
private function normalizeScalar($data) {
		if (null === $data || is_scalar($data)) {
			/*// utf8_encode only works for Latin1 so we rely on mbstring
			if (is_string($data)) {
				$data = mb_convert_encoding($data, "UTF-8");
			}*/

			if (is_float($data)) {
				$data = $this->normalizeFloat($data);
			}

			return $data;
		}

		return [];
	}
1295346
public static function fromArray(array $data = [])
    {
        $value = isset($data['value']) ? (float)$data['value'] : 0.0;

        try {
            $comparisonOperator = isset($data['comparison_operator']) ? ComparisonOperator::create($data['comparison_operator']) : null;
        } catch (\Exception $e) {
            $comparisonOperator = null;
        }

        return new self($value, $comparisonOperator);
    }
93742
private static function _parseData(array $data)
    {
        foreach($data as $key => $value) {
            self::$_data[\mb_strtolower($key)] = $value;
        }
    }
964713
private function calculateChecksum($data) {
    if (strlen($data) % 2) {
      $data .= "\x00";
    }

    $bit = unpack('n*', $data);
    $sum = array_sum($bit);

    while ($sum >> 16) {
      $sum = ($sum >> 16) + ($sum & 0xffff);
    }

    return pack('n*', ~$sum);
  }
1258312
public function unserialize($data)
    {
        $vars = unserialize($data);
        foreach ($vars as $var => $value) {
            $this->{$var} = $value;
        }
    }
966796
private function priceAdjuster($price) {
        // min,max, value
        $price_ranges = [
            [01, 29, 29],
            [30, 49, 49],
            [50, 79, 79],
            [80, 99, 99],
            [00, 00, 99],
        ];

        list($whole, $decimal) = explode('.', $price);

        foreach ($price_ranges as &$value) {
            if($decimal >= $value[0] && $decimal <= $value[1]) {
                $decimal = $value[2];
                break;
            }
        }

        $price = $whole.'.'.$decimal;

        return floatval($price);
    }
1026555
public function initFromArray(array $data) {

        $this->traitInitFromArray($data);

        if (!empty($data['buy'])) {
            $this->setBuy((new LimitActionPart())->initFromArray($data['buy']));
        }

        if (!empty($data['instant_buy'])) {
            $this->setInstantBuy((new LimitActionPart())->initFromArray($data['instant_buy']));
        }

        if (!empty($data['sell'])) {
            $this->setSell((new LimitActionPart())->initFromArray($data['sell']));
        }

        if (!empty($data['deposit'])) {
            $this->setDeposit((new LimitActionPart())->initFromArray($data['deposit']));
        }

        return $this;

    }
791450
public function set(array $data)
	{
		foreach ($data as $key => $value)
		{
			if (isset(static::$_mass_whitelist))
			{
				in_array($key, static::$_mass_whitelist) and $this->_data[$key] = $value;
			}
			elseif (isset(static::$_mass_blacklist))
			{
				( ! in_array($key, static::$_mass_blacklist)) and $this->_data[$key] = $value;
			}
			else
			{
				// no static::$_mass_whitelist or static::$_mass_blacklist set, proceed with default behavior
				$this->_data[$key] = $value;
			}
		}
		return $this;
	}
375203
public static function createFromData(array $data)
    {
        if (!isset($data['type'])) {
            throw new DomainException(self::MSG_REQUIRED_TYPE);
        }

        switch ($data['type']) {
            case self::TYPE_FIXED:
                $discount = new Discounts\Fixed($data);

                break;
            case self::TYPE_PERCENT:
                $discount = new Discounts\Percent($data);

                break;
            default:
                throw new DomainException(
                    sprintf(self::MSG_UNSUPPORTED_TYPE, implode(',', self::$supportedTypes))
                );
        }

        return $discount;
    }