Normalizes a value to make sure it can be processed uniformly.

@param mixed $value
@param bool  $original
@return mixed
547058
protected function normalizeValue($value, $original = false)
    {
        if (is_array($value)) {
            return $value;
        }

        if ($value instanceof Arrayable) {
            return $value->toArray();
        }

        return [ $value => [] ];
    }
659048
protected function transformValue($value)
    {
        // first of all remove any quotation marks
        $value = preg_replace('/("|\')(.+)("|\')/', '$2', $value);

        $this->transformToDate($value);
        $this->transformToFloat($value);
        $this->transformToInt($value);

        return $value;
    }
56131
private function internalSetValue($value)
    {
        if (is_float($value)) {
            $valueToSet = Utils::convertExponentialToString($value);
        } else {
            $valueToSet = (string)$value;
        }

        if (!is_numeric($valueToSet)) {
            throw new InvalidArgumentException('Invalid number provided: ' . $valueToSet);
        }

        // We use a slick trick to make sure the scale is respected.
        $this->value = bcadd(0, $valueToSet, $this->getScale());

        return $this;
    }
662252
protected function normalizeScrape($value)
	{
		if (!empty($value) && !isset($value[0]))
		{
			$value = [$value];
		}
		foreach ($value as &$scrape)
		{
			$scrape           += ['extract' => [], 'match' => '//'];
			$scrape['extract'] = $this->normalizeRegexp($scrape['extract']);
			$scrape['match']   = $this->normalizeRegexp($scrape['match']);
		}
		unset($scrape);

		return $value;
	}
457542
public static function transform($value, callable $callback, $default = null)
    {
        if (self::filled($value)) {
            return $callback($value);
        }

        if (\is_callable($default)) {
            return $default($value);
        }

        return $default;
    }
1016298
private function castValue(string $value)
    {
        $value = $this->normalize($value);
        if (\preg_match('/^[0-9]+$/', $value)) {
            $value = (int)$value;
        } elseif (\preg_match('/^[0-9\.]+$/', $value)) {
            $value = (float)$value;
        } elseif (\preg_match('/^true|false$/', $value)) {
            $value = $value === 'true' ? true : false;
        }
        return $value;
    }
778597
public function reverseTransform($value)
    {
        if (!is_scalar($value)) {
            throw new TransformationFailedException('Expected a scalar.');
        }

        if ('' === $value) {
            return null;
        }

        $result = $value;

        if (!is_numeric($result)) {
            throw new TransformationFailedException('Value is not numeric.');
        }

        if (\is_string($result)) {
            if (false !== mb_strpos($result, '.')) {
                $result = (float) $result;
            } else {
                $result = (int) $result;
            }
        }

        if ($result >= PHP_INT_MAX || $result <= -PHP_INT_MAX) {
            throw new TransformationFailedException('I don\'t have a clear idea what infinity looks like.');
        }

        return $this->round($result);
    }
63219
protected function normalizeValue($value)
    {
        if (is_null($value)) {
            return $value;
        }

        $entityClass = $this->getEntity();
        // Validate Many2many attribute value
        if (!$this->isArray($value) && !$this->isArrayObject($value) && !$this->isInstanceOf($value, EntityCollection::class)) {
            $exception = new ValidationException(ValidationException::DATA_TYPE, [
                'array, ArrayObject or EntityCollection',
                gettype($value)
            ]);
            $exception->setAttribute($this->getName());
            throw $exception;
        }

        /* @var $entityAttribute One2ManyAttribute */
        $values = [];
        foreach ($value as $item) {
            $itemEntity = false;

            // $item can be an array of data, AbstractEntity or a simple mongo ID string
            if ($this->isInstanceOf($item, $entityClass)) {
                $itemEntity = $item;
            } elseif ($this->isArray($item) || $this->isArrayObject($item)) {
                $itemEntity = $entityClass::findById(isset($item['id']) ? $item['id'] : false);
            } elseif ($this->isString($item) && Entity::getInstance()->getDatabase()->isId($item)) {
                $itemEntity = $entityClass::findById($item);
            }

            // If instance was not found, create a new entity instance
            if (!$itemEntity) {
                $itemEntity = new $entityClass;
            }

            // If $item is an array - use it to populate the entity instance
            if ($this->isArray($item) || $this->isArrayObject($item)) {
                $itemEntity->populate($item);
            }

            $values[] = $itemEntity;
        }

        return new EntityCollection($this->getEntity(), $values);
    }
729490
private static function normalizeValue($value)
    {
        if (is_string($value)) {
            $value = str_ireplace(['&nbsp;', '&#160;'], ' ', $value);
            $value = trim($value);

            return ($value === '') ? null : $value;
        }

        return $value;
    }
1208327
protected function processValue($value)
    {
        if (is_array($value)) {
            
            // Handle Array Value:
            
            $value = $this->processArray($value);
            
        } else {
            
            // Handle String Value:
            
            $value = trim($value);
            
            if ($this->isReference($value)) {
                return $this->processReference($value);
            }
            
        }
        
        // Answer Value:
        
        return $value;
    }
1328429
public function prepareValue($value)
    {
        return $value === null ? null : Carbon::createFromFormat($this->format, $value)->toDateString();
    }
47513
protected function normalizeValue($value)
    {
        $normalizedValue = $value;
        // object value
        if (is_object($value)) {
            if (get_class($value) === "DateTime") {
                $normalizedValue = $value->format("Y-m-d\TH:i:s.u\Z");
            } elseif ($value instanceof DataContainerInterface || method_exists($value, 'normalizeData')) {
                $normalizedValue = $value->normalizeData();
            } else {
                throw new PropertyValueNormalizationException(
                    "Value error: object of type [" . get_class($value) . "]
                    does not implement DataContainerInterface nor have a [normalizeData] method"
                );
            }
        } elseif (is_array($value)) {
            foreach ($value as $arrProperty => $arrValue) {
                $normalizedValue[$arrProperty] = $this->normalizeValue($arrValue);
            }
        }

        return $normalizedValue;
    }
557161
protected function _setDefaultPlaceholderValue($value)
    {
        if (!is_null($value)) {
            $value = $this->_normalizeStringable($value);
        }

        $this->defaultPlaceholderValue = $value;
    }
372069
protected function getDefaultValue($value)
    {
        if ($value instanceof Expression) {
            return $value;
        }

        return is_bool($value)
            ? "'" . (int) $value . "'"
            : "'" . strval($value) . "'";
    }
192725
protected function parseValue($value){
		switch( true ){
			case ($value === 'false' || $value === 'true'):
				return  ( $value === 'true' ) ? true : false ;
			
			case ctype_digit($value):
				return (int) $value; 

			case is_float($value):
				return (float) $value;

			default:
				return $value;
		}
	}
1311316
protected function normalizeValue($value)
    {
        if (is_array($value)) {
            return implode(',', $value);
        } elseif (is_bool($value)) {
            return $value ? 'true' : 'false';
        }

        return $value;
    }
1208477
public static function normalize($value)
    {
        $convert = localeconv();
        $value = str_replace($convert['thousands_sep'], "",(string) $value);
        $value = str_replace($convert['positive_sign'], "", $value);
        $value = str_replace($convert['decimal_point'], ".",$value);
        if (!empty($convert['negative_sign']) and (strpos($value, $convert['negative_sign']))) {
            $value = str_replace($convert['negative_sign'], "", $value);
            $value = "-" . $value;
        }

        return $value;
    }