Internal function utilized by getValueAttribute to get raw results from the db and format as they were set during insertion.

@param $value
@return bool|float|Collection|int|mixed
347890
private function getValue($value)
    {
        switch ($this->attributes['type']) {
            case 'int':
            case 'integer':
                return (int) $value;
            case 'real':
            case 'float':
            case 'double':
                return (float) $value;
            case 'bool':
            case 'boolean':
                return (bool) $value;
            case 'collection':
                return new Collection(json_decode($value, true));
            case 'object':
                return json_decode($value);
            case 'array':
                return json_decode($value, true);
            default:
                return $value;
        }
    }
613719
public function getTypeFromValue($value = null)
    {
        $value = ($value == null ? $this->value : $value);
        return array_search($value, self::$codeList);
    }
710061
public function createAttributeValue($value)
    {
        $av = new NumberValue();
        $value = ($value == false || $value == '0') ? 0 : $value;
        $av->setValue($value);

        return $av;
    }
613105
public static function parseValue($value)
    {
        if ($value instanceof DateTimeInterface) {
            $value = $value->format('Y-m-d H:i:s');
        } elseif ($value instanceof DateTimeProperty) {
            $value = $value->storageVal($value->val());
        } elseif (is_string($value)) {
            $str = strtolower($value);
            if ($str === 'true') {
                $value = true;
            } elseif ($str === 'false') {
                $value = false;
            }
        }

        return $value;
    }
1169413
private function sregValue($value = '')
    {
        $owner = $this->owner;
        $values = explode('|', $value);
        $count = count($values);
        foreach ($values as $key => $fieldPath) {
            if ($fieldPath == '' || $fieldPath == 'null') {
                return null;
            } elseif ($relValue = $this->sregTraverse($fieldPath)) {
                if (is_object($relValue) && method_exists($relValue, 'AbsoluteLink')) {
                    if ($link = $relValue->AbsoluteLink()) {
                        return $link;
                    } else {
                        continue;
                    }
                } else {
                    return $relValue;
                }
            } elseif ($key + 1 == $count && !$owner->hasMethod($fieldPath) ) {
                return $fieldPath;
            }
        }
    }
696445
public function filter($value)
    {
        if (empty($value)) {
            return $value;
        }

        return number_format(floatval($value), $this->decimals, $this->decimalPoint, $this->thousandSeparator);
    }
507833
public function toBigQuery($value)
    {
        if ($value instanceof ValueInterface || $value instanceof Int64) {
            return (string) $value;
        }

        if ($value instanceof \DateTime) {
            return $value->format(self::DATETIME_FORMAT_INSERT);
        }

        if (is_array($value)) {
            foreach ($value as $key => $item) {
                $value[$key] = $this->toBigQuery($item);
            }

            return $value;
        }

        return $value;
    }
397942
public function getValueAttribute($value)
    {
        if (!is_array($value)) {
            $decodedValue = json_decode($value, true);
        }

        //Not a JSON string.
        if (!empty($value) && empty($decodedValue)) {
            $decodedValue = $value;
        }

        return $decodedValue;
    }
1291139
protected function getValue($value)
    {
        if (is_numeric($value)) {
            return false !== strpos('.', $value) ? (double)$value : (int)$value;
        }
        return $value;
    }
1198516
public function filter($value)
    {
        if ($value === '' || $value === null) {
            return $value;
        }

        if (!is_string($value) && !is_int($value) && !$value instanceof DateTime) {
            return $value;
        }

        /**
         * We try to create a \DateTime according to the format. If the creation fails, we return the string itself.
         * So it's treated by Validate\Date
         */
        $date = is_int($value) ? date_create("@$value") // from timestamp
            : PhpDateTime::createFromFormat($this->format, $value);

        // Invalid dates can show up as warnings (ie. "2007-02-99") and still return a DateTime object
        $errors = PhpDateTime::getLastErrors();

        if ($date === false || (array_key_exists('warning_count', $errors) && $errors['warning_count'] > 0)) {
            return $value;
        }

        return DateTime::instance($date);
    }
646978
protected function unserialize($value)
    {
        if (filter_var($value, FILTER_VALIDATE_INT) !== false) {
            return (int) $value;
        }

        if (is_numeric($value)) {
            return (float) $value;
        }

        return unserialize($value);
    }
636505
private function addIntoAllowedValues($value)
    {
        if (empty($this->getType())) {
            return false;
        }

        if (in_array(
                $value,
                $this->allowedValues
        )) {
            return false;
        }

        switch ($this->getType()) {
            case 'int' :
                $value = intval($value);

                $this->allowedValues[] = $value;

                return true;

            case 'float' :
                $value = floatval($value);

                $this->allowedValues[] = $value;

                return true;
            case 'string' :
                $value = (string)$value;

                $this->allowedValues[] = $value;

                return true;
            default:

                return false;
        }
    }
942828
private function getValue($value)
    {
        if (!is_string($value)) {
            return $value;
        }

        if ($value[0] != '%' || $value[strlen($value) - 1] != '%')  {
            return $value;
        }

        $parameter = trim($value, '%');
        if ($this->container->hasParameter($parameter)) {
            return $this->container->getParameter($parameter);
        }

        return $value;
    }
983659
public function serialize($value) {
        $filters = $this->getFilters();
        for ($i = count($filters) - 1; $i >= 0; --$i) {
            $value = $filters[$i]->fromValue($value);
        }
        return $this->toData($value);
    }
1189592
public static function getType($value)
    {
        if (is_int($value)) {
            return MDataType::INT;
        }

        if (is_long($value)) {
            return MDataType::LONG;
        }

        if (is_bool($value)) {
            return MDataType::BOOLEAN;
        }

        if (is_float($value)) {
            return MDataType::FLOAT;
        }

        if (is_double($value)) {
            return MDataType::DOUBLE;
        }

        if (is_string($value)) {
            return MDataType::STRING;
        }

        if ($value == null) {
            return MDataType::NULL;
        }

        if (is_array($value)) {
            return MDataType::__ARRAY;
        }

        if (is_object($value)) {
            return MDataType::OBJECT;
        }

        if (is_resource($value)) {
            return MDataType::RESOURCE;
        }

        return MDataType::UNKNOWN;
    }
454720
protected function getIdFromValue(string $value)
    {
        try {
            if (null !== $item = $this->getIriConverter()->getItemFromIri($value, ['fetch_data' => false])) {
                return $this->getPropertyAccessor()->getValue($item, 'id');
            }
        } catch (InvalidArgumentException $e) {
            // Do nothing, return the raw value
        }

        return $value;
    }
1364887
public function numToBinary($value)
    {
        $saved_object_count = $this->writtenObjectCount++;

        $val = "";
        if (intval($value) == $value && !is_float($value) && strpos($value, '.') === false) {
            $val = $this->intToBinary($value);
        } else {
            $val = $this->realToBinary($value);
        }

        $this->objectTable[$saved_object_count] = $val;
        return $saved_object_count;
    }