Apply a series of transformations defined as closures in the configuration file.

@param string $string

@return string
849
private function applyTransformers(string $string): string
    {
        foreach (Transformer::getAll() as $transformer) {
            $string = $transformer($string);
        }

        return $string;
    }
641092
protected function normalizeString($string)
    {
        if (false === strpos($string, '_')) {
            return $string;
        }

        return preg_replace_callback('/_([a-zA-Z0-9])/', function ($matches) {
            return strtoupper($matches[1]);
        }, $string);
    }
1129205
public static function pluralise( $string ) {

		// save some time in the case that singular and plural are the same
		if ( in_array( mb_strtolower( $string ), self::$uncountable ) )
			return $string;


		// check for irregular singular forms
		foreach ( self::$irregular as $pattern => $result )
		{
			$pattern = '/' . $pattern . '$/iu';

			if ( preg_match( $pattern, $string ) )
				return preg_replace( $pattern, $result, $string);
		}

		// check for matches using regular expressions
		foreach ( self::$plural as $pattern => $result )
		{
			if ( preg_match( $pattern, $string ) )
				return preg_replace( $pattern, $result, $string );
		}

		return $string;

	}
1255659
public function escapeString($string)
    {
        if (func_num_args() < 2) {
            if (strpos($string, "\n") !== false) {
                return array('{' . strlen($string) . '}', $string);
            } else {
                return '"' . str_replace(array('\\', '"'), array('\\\\', '\\"'), $string) . '"';
            }
        }
        $result = array();
        foreach (func_get_args() as $string) {
            $result[] = $this->escapeString($string);
        }
        return $result;
    }
1075240
public function apply(string $string) : string
    {
        return str_replace($this->search, $this->replace, $string);
    }
417984
public static function fromString($string)
    {
        \Assert\that($string)
            ->string('Argument has to be a string')
            ->uuid('String has to be an UUID');

        return new static(Uuid::fromString($string));
    }
334968
public function translate($string)
    {
        $args = func_get_args();
        $translated = array_shift($args);
        $extraParams = $args;
        if (count($extraParams)>0)
        {
            $translated = vsprintf($translated, $extraParams);
        }

        return $translated;
    }
1015583
public function transform($string)
    {
        $xml = simplexml_load_string($string);

        if (false === $xml) {
            throw new \Exception('Unable to parse xml string.');
        }

        return  $this->xmlToArray($xml)['feed'];
    }
795348
public static function plural($string)
    {
        $result = $string;
        foreach (self::$_plural as $rule => $replacement) {
            $rule = self::_normalize($rule);
            if (preg_match($rule, $string)) {
                $result = preg_replace($rule, $replacement, $string);
                break;
            }
        }
        return $result;
    }
534307
public function apply(string $string) : string
    {
        return preg_replace($this->pattern, $this->replacement, $string);
    }
57164
public function normalize($string) {
		$string = $this->_normalize($string, ['clean' => true, 'case' => true]);
		return implode('-', str_split($string, $this->_partLength));
	}
743836
public function getTidy($string)
    {
        if (class_exists('Tidy')) {
            if (!$this->_tidy) {
                $this->_tidy = new Tidy();
            }

            $this->_tidy->parseString($string, $this->_config, $this->_encoding);
        }

        return $this->_tidy;
    }
1180609
public static function className($string) {
        return static::cache(array(__METHOD__, $string), function() use ($string) {
            return Inflector::camelCase(Inflector::singularize($string));
        });
    }
959065
protected function replace($string)
    {
        foreach ($this->patterns as $key => $value) {
            $string = str_replace($key, $value, $string);
        }

        return $string;
    }
517761
public function transform($string)
    {
        $string = preg_replace('/[^\p{L&}\p{Lo}\d]/u', $this->replacement, $string);
        $string = preg_replace('/[' . preg_quote($this->replacement) . ']+/u', $this->replacement, $string);
        $string = trim($string, $this->replacement);
        return $this->lowercase ? mb_strtolower($string) : $string;
    }
38314
public static function singularise( $string ) {

		// save some time in the case that singular and plural are the same
		if ( in_array(mb_strtolower($string), self::$uncountable) )
			return $string;

		// check for irregular plural forms
		foreach( self::$irregular as $result => $pattern ) {
			$pattern = '/' . $pattern . '$/iu';
			if( preg_match($pattern, $string) )
				return preg_replace($pattern, $result, $string);
		}

		// check for matches using regular expressions
		foreach( self::$singular as $pattern => $result ) {
			if( preg_match($pattern, $string) )
				return preg_replace($pattern, $result, $string);
		}

		return $string;

	}
298947
protected function clean($string)
    {
        $string = str_replace($this->getDelimiter(), '_', Container::underscore($string));
        // fixes underscores removed by the Container::underscore()
        $string = str_replace('.', '_', $string);
        $string = preg_replace('/[^A-Za-z0-9_]/', '', $string);
        
        return preg_replace('/_+/', '_', $string);
    }