Replaces all ambiguous characters in a submitted values with the intended characters.

@param string|null $value The submitted value.

@return string|null

@since 1.0.0
@api
325785
public function clean($value)
  {
    // Return null for empty strings.
    if ($value==='' || $value===null || $value===false)
    {
      return null;
    }

    // Replace all ambiguous characters.
    $tmp = $value;
    foreach ($this->ambiguities as $unambiguity => $ambiguities)
    {
      foreach ($ambiguities as $ambiguity)
      {
        // Note: str_replace works fine with multi byte characters like UTF-8.
        $tmp = str_replace($ambiguity, $unambiguity, $tmp);
      }
    }

    // Restore EOL for DOS users.
    if (PHP_EOL!="\n") $tmp = str_replace("\n", PHP_EOL, $tmp);

    // Return null for empty strings.
    if ($tmp==='') $tmp = null;

    return $tmp;
  }
1046176
public function filter($value)
    {
        if (!is_scalar($value) && !is_array($value)) {
            return $value;
        }

        // a unicode safe way of converting characters to \x00\x00 notation
        $pregQuotedSeparator = preg_quote($this->separator, '#');

        if (StringUtils::hasPcreUnicodeSupport()) {
            $patterns = [
                '#(' . $pregQuotedSeparator.')(\P{Z}{1})#u',
                '#(^\P{Z}{1})#u',
            ];
            if (!extension_loaded('mbstring')) {
                $replacements = [
                    function ($matches) {
                        return strtoupper($matches[2]);
                    },
                    function ($matches) {
                        return strtoupper($matches[1]);
                    },
                ];
            } else {
                $replacements = [
                    function ($matches) {
                        return mb_strtoupper($matches[2], 'UTF-8');
                    },
                    function ($matches) {
                        return mb_strtoupper($matches[1], 'UTF-8');
                    },
                ];
            }
        } else {
            $patterns = [
                '#(' . $pregQuotedSeparator.')([\S]{1})#',
                '#(^[\S]{1})#',
            ];
            $replacements = [
                function ($matches) {
                    return strtoupper($matches[2]);
                },
                function ($matches) {
                    return strtoupper($matches[1]);
                },
            ];
        }

        $filtered = $value;
        foreach ($patterns as $index => $pattern) {
            $filtered = preg_replace_callback($pattern, $replacements[$index], $filtered);
        }
        return $filtered;
    }
575611
public function clean($value)
  {
    if ($value==='' || $value===null || $value===false)
    {
      return null;
    }

    $tmp = PruneWhitespaceCleaner::get()->clean($value);
    if ($tmp==='' || $tmp===null)
    {
      return null;
    }

    return mb_substr($tmp, 0, $this->maxLength);
  }
1272434
public function asNtext($value)
    {
        if ($value === null) {
            return $this->getNullDisplay();
        }

        return nl2br(Html::encode($value));
    }
1085906
public static function encode($value, $ignore = null)
    {
        if (null === $ignore) {
            $ignore = static::CHAR_UNRESERVED
                    . static::CHAR_GEN_DELIMS
                    . static::CHAR_SUB_DELIMS;
        }
        $rawurlencode = function (array $matches) {
            return rawurlencode($matches[0]);
        };

        return preg_replace_callback(
            '/(?:[^' . $ignore . '%]+|%(?![A-Fa-f0-9]{2}))/',
            $rawurlencode,
            $value
        );
    }
91963
protected function sanitize($value)
    {
        $value = escapeshellarg(trim((string) $value));
        $value = str_replace("\n", ' ', $value);

        return $value;
    }
198825
private function parseOptionValue($value = null)
    {
        if (\is_bool($value)) {
            $value = $value === true ? 'true' : 'false';
        } elseif (\is_null($value)) {
            $value = 'null';
        } elseif (\is_string($value)) {
            $value = '\''.$value.'\'';
        }
        return $value;
    }
1157138
public static function toString($value)
    {
        if($value == null)
        {
            return null;
        }
        $reflection = new \ReflectionClass(static::class);
        $values = $reflection->getConstants();

        //Check if input value is valid
        if(static::isValid($value, $reflection))
        {
            $constName = array_search($value, $values);
            return static::WordifyConst($constName);
        }
        else
        {
            return null;
        }
    }
733016
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

        if (!$value instanceof Language) {
            throw new TransformationFailedException('Expected a ' . Language::class . ' object.');
        }

        return $value->languageCode;
    }
165405
public function quoteString(?string $value): string
  {
    if ($value===null || $value==='') return 'null';

    return "'".$this->mysqli->real_escape_string($value)."'";
  }
290489
protected function _validate_email($value)
    {
        $value = trim($value);

        return ($value === '' || filter_var($value, FILTER_VALIDATE_EMAIL) !== false) ? strtolower($value) : null;
    }
964305
public function coerceLiteral(Node $value)
    {
        if ($value instanceof EnumValue) {
            $key = $value->get('value');
            if (($lookup = $this->getNameLookup()) && isset($lookup[$key])) {
                return $lookup[$key] ? $lookup[$key]->getName() : NULL;
            }
        }

        return NULL;
    }
1144840
protected function _sanitize($value)
    {
        $value = trim($value);

        $parts  = explode('-', $value, 2);
        if (2 != count($parts)) {
            return null;
        }

        $parts[0]   = substr(preg_replace('/[^a-z]*/', '', $parts[0]), 0, 2);
        $parts[1]   = substr(preg_replace('/[^A-Z]*/', '', $parts[1]), 0, 2);
        $result = implode('-', $parts);

        // just making sure :-)
        if ($this->_validate($result)) {
            return $result;
        }

        return null;
    }
1020188
protected function encodeDate(DateTime $value = null) {
        return null === $value ? "" : $value->format(self::DATE_FORMAT);
    }
1081508
protected function _encodeDatum(&$value)
    {
        $result = 'null';

        if (is_int($value) || is_float($value)) {
            $result = (string)$value;
        } elseif (is_string($value)) {
            $result = $this->_encodeString($value);
        } elseif (is_bool($value)) {
            $result = $value ? 'true' : 'false';
        }

        return $result;
    }
1279328
public function clean($value)
  {
    if ($value==='' || $value===null || $value===false)
    {
      return null;
    }

    $tmp = AmbiguityCleaner::get()->clean($value);

    $tmp = str_replace([' ', "\t", "\n"], '', $tmp);
    if ($tmp==='') $tmp = null;

    return $tmp;
  }
526971
public function transform($value)
    {
        if (trim($value) == '')
            return null;

        if (preg_match('/^(?:(.+) )?<(.+)>$/', $value, $matches)) {
            return new Address($matches[2], $matches[1]);
        }

        throw new AddressException(sprintf('Unable to parse Address "%s".', $value));
    }