Prepares the data for output

@param  mixed $value
@return mixed
324862
protected function prepareData($value)
    {
        if (is_string($value)) {
            return stripslashes(trim(str_replace('\n', "\n", $value)));
        } elseif (is_array($value)) {
            return array_map('self::prepareData', $value);
        }

        return $value;
    }
204344
public function set($value)
    {
        return (
            ($this->value = $this->clean($value, true, false)) &&
            ($this->rawValue = $value)
        );
    }
1363766
protected function serialize($value)
    {
        if (!is_array($value)) {
            return $value;
        }
        return Serialize::serialize($value, $this->serializer);
    }
658445
protected static function dumpArray($value)
  {
    // array
    $keys = array_keys($value);
    if (
      (1 == count($keys) && '0' == $keys[0])
      ||
      (count($keys) > 1 && array_reduce($keys, create_function('$v,$w', 'return (integer) $v + $w;'), 0) == count($keys) * (count($keys) - 1) / 2))
    {
      $output = array();
      foreach ($value as $val) {
        $output[] = self::dump($val);
      }

      return sprintf('[%s]', implode(', ', $output));
    }

    // mapping
    $output = array();
    foreach ($value as $key => $val) {
      $output[] = sprintf('%s: %s', self::dump($key), self::dump($val));
    }

    return sprintf('{ %s }', implode(', ', $output));
  }
1162737
protected function prepareValue($value)
    {
        $value = $this->asDateTime($value)->startOfDay();

        return $value->format($this->getDateFormat());
    }
360741
function prepValueForDB($value) {
		if(!$this->nullifyEmpty && $value === '') {
			return DB::getConn()->prepStringForDB($value);
		} else {
			return parent::prepValueForDB($value);
		}
	}
680007
public function serialize($value)
    {
        $this->reset();

        return $this->serializationStrategy->serialize($this->serializeData($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;
    }
1030486
public function prepare($value)
    {
        if (is_string($value) && preg_match_all('/\%([^\%]+)\%/', $value, $match)) {
            foreach ($match[1] as $match) {
                try {
                    $value = str_replace("%{$match}%", $this->get($match), $value);
                } catch (\Exception $e) {
                    throw new \Exception("Configuration Missing for %" . $match . "%");
                }
            }
        } elseif (is_array($value)) {
            $result = array();

            foreach ($value as $key => $item) {
                $result[$key] = $this->prepare($item);
            }

            $value = $result;
        }

        return $value;
    }
1123505
public static function format($value)
    {
        $value = Utils::toString($value);
        $bn = Utils::toBn($value);
        $int = (int) $bn->toString();

        return $int;
    }
688868
public function serialize($value)
    {
        if ($this->getDataType() === 'json') {
            return json_encode($value);
        } elseif ($this->getDataType() === 'array') {
            return json_encode($value);
        } elseif ($this->getDataType() === 'list') {
            return implode(',', $value);
        }

        return trim($value);
    }
1042997
public static function prepareToStore($value)
    {
        // if array - try to prepare every value
        if (is_array($value)) {
            foreach ($value as $k => $v) {
                $value[$k] = self::prepareToStore($v);
            }

            return $value;
        }

        // if scalar - return it
        if (!is_object($value)) {
            return $value;
        }

        // if internal mongo types - pass it as is
        if (TypeChecker::isInternalType($value)) {
            return $value;
        }

        // do not convert geo-json to array
        if ($value instanceof Geometry) {
            return $value->jsonSerialize();
        }

        // structure
        if ($value instanceof Structure) {
            // validate structure
            if (!$value->isValid()) {
                $exception = new InvalidDocumentException('Embedded document not valid');
                $exception->setDocument($value);
                throw $exception;
            }

            // get array from structure
            return $value->toArray();
        }

        // other objects convert to array
        return (array) $value;
    }
1373967
public function dump($value)
    {
        switch (gettype($value)) {
            // Handle boolean values.
            case "boolean": {
                $output = $value ? "true" : "false";

                // You can represent booleans (and NULLs) in either lower- or uppercase format.
                return $this->config["bool_lowercase"] ? $output : strtoupper($output);
            }

            // Handle NULL values.
            case "NULL": {
                return $this->config["null_lowercase"] ? "null" : "NULL";
            }

            // Handle integers.
            case "integer": {
                return (string) $value;
            }

            // Handle floats (doubles).
            case "double": {
                // Dumpy allows you to round floats to round_double decimal points.
                if ($this->config["round_double"] !== false) {
                    $value = round($value, $this->config["round_double"], PHP_ROUND_HALF_UP);
                }

                return (string) $value;
            }

            // Handle strings.
            case "string": {
                // @suggestion Multibyte support?
                // Look above for the detailed explanation.
                if (strlen($value) > $this->config["str_max_length"]) {
                    $value = substr($value, 0, $this->config["str_max_length"]) . "...";
                }

                // Dumpy allows you to replace newline characters with "\\n".
                if ($this->config["replace_newline"]) {
                    $value = str_replace(PHP_EOL, "\\n", $value);
                }

                return "\"{$value}\"";
            }

            // Handle arrays.
            case "array": {
                return $this->printArray($value) . PHP_EOL;
            }

            // Handle objects.
            case "object": {
                return $this->printObject($value);
            }
            // @codeCoverageIgnoreStart
        }
    }
370804
protected function formatValue($value)
    {
        if (is_array($value)) {
            return Formatter::formatArray($value);
        }

        return Formatter::formatScalar($value);
    }
331723
protected function formatValue($value)
    {
        if ($this->formatValue !== NULL) {
            return str_replace(static::VALUE_IDENTIFIER, $value, $this->formatValue);
        } else {
            return $value;
        }
    }
699872
public function prepareResponse($value)
	{
		if ( ! $value instanceof SymfonyResponse) $value = new Response($value);

		return $value->prepare($this['request']);
	}
204211
public function _prepValues($value)
    {
        if (is_array($value)) {
            if (isset($value["func"])) {
                return $value["func"];
            }
            foreach ($value as &$param) {
                $this->params[] = $param;
                $param = "?";
            }
            unset($param);
            return $value;
        }
        if (in_array(is_string($value) ? strtolower($value) : $value, [null, "null"]) === false) {
            $this->params[] = $value;
            $value = "?";
        }
        return $value;
    }