Returns the singular version of the given string.

@param string $string Singular string to evaluate.

@return string The singular version of the provided string.
762860
public static function singular($string)
    {
        $result = $string;
        foreach (self::$_singular as $rule => $replacement) {
            $rule = self::_normalize($rule);
            if (preg_match($rule, $string)) {
                $result = preg_replace($rule, $replacement, $string);
                break;
            }
        }
        return $result;
    }
15862
public static function studlyCase($string) {
    $string = Strings::capitalize(Strings::replace($string, ['/-/', '/_/'], ' '));
    return Strings::replace($string, '/ /');
  }
684991
protected function _obscureString($string)
    {
        $len = strlen($string);
        if ($len > 3) {
            return substr($string, 0, 1) . str_repeat('*', $len - 2) . substr($string, -1);
        }

        return str_repeat('*', $len);
    }
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;

	}
291998
public function ucFirst($string)
    {
        $first = $this->sub($string, 0, 1);
        $first = $this->upp($first);

        return $first . $this->sub($string, 1);
    }
1195641
public static function cleanExtension(?string $string): ?string
    {
        // no extension in string is founded
        if (!self::contains('.', $string)) {
            return $string;
        }

        $splited = explode('.', $string);
        array_pop($splited);
        return implode('.', $splited);
    }
702813
public static function clearString( string $string ) {
		$string = trim( $string );
		$string = stripslashes( $string );
		$string = htmlspecialchars( $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);
    }
1141962
protected function translate($string)
    {
        if ($this->hasTranslator()) {
            return $this->getTranslator()->translate($string, $this->getTranslatorTextDomain());
        }

        return $string;
    }
119157
public function compare($string)
    {
        if (\class_exists('\Collator', false)) {
            static $collator = null;
            if ($collator === null) {
                $collator = new \Collator(\setlocale(LC_COLLATE, null));
            }

            return $collator->compare($this->_string, $string);
        }

        return \strcmp($this->_string, (string) $string);
    }
310008
protected function inflect($string)
    {
        if (null === $this->inflector) {
            return $string;
        }

        return call_user_func($this->inflector, $string);
    }
302916
public static function singularize($string)
    {
        $singular = [
            '/(vert|ind)ices$/i' => '$1ex',
            '/(alias)es$/i' => '$1',
            '/(x|ch|ss|sh)es$/i' => '$1',
            '/(s)eries$/i' => '$1eries',
            '/(s)tatus$/i' => '$1tatus',
            '/([^aeiouy]|qu)ies$/i' => '$1y',
            '/([lr])ves$/i' => '$1f',
            '/([ti])a$/i' => '$1um',
            '/(us)es$/i' => '$1',
            '/(basis)$/i' => '$1',
            '/([^s])s$/i' => '$1',
        ];

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

        //Else return
        return $string;
    }
719838
final public static function handlifyString($string)
    {
        $string = preg_replace('/\W+/', '_', $string);
        $string = preg_replace('/([A-Z])/', '_$1', $string);
        $string = strtolower($string);
        $string = preg_replace('/_+/', '_', trim($string, '_'));

        return $string;
    }
1337568
public function string($string = NULL)
	{
		if (func_num_args() === 0)
		{
			return $this->_string;
		}
		$this->_string = $string;
		return $this;
	}
444143
public static function fromString($string)
	{
		$lowercaseString = trim(strtolower($string), "\\");

		// TODO: variant types

		if ($lowercaseString === "mixed") {
			return MixedType::getInstance();

		} elseif ($lowercaseString === "scalar") {
			return ScalarType::getInstance();

		} elseif ($lowercaseString === "object") {
			return ObjectType::getInstance();

		} elseif ($lowercaseString === "void" || $lowercaseString === "null") {
			return VoidType::getInstance();

		} elseif ($lowercaseString === "numeric" || $lowercaseString === "number") {
			return NumericType::getInstance();

		} elseif ($lowercaseString === "int" || $lowercaseString === "integer") {
			return IntType::getInstance();

		} elseif ($lowercaseString === "float" || $lowercaseString === "double") {
			return FloatType::getInstance();

		} elseif ($lowercaseString === "bool" || $lowercaseString === "boolean") {
			return BoolType::getInstance();

		} elseif ($lowercaseString === "string") {
			return StringType::getInstance();

		} elseif ($lowercaseString === "resource" || $lowercaseString === "stream") {
			return ResourceType::getInstance();

		} elseif ($lowercaseString === "callable" || $lowercaseString === "callback" || trim($lowercaseString, "\\") === "closure") {
			return CallableType::getInstance();

		} elseif (strncmp($lowercaseString, "array", 5 /* strlen("array") */) === 0) {
			return ArrayType::create(MixedType::getInstance());

		} else {
			if (func_num_args() > 1) {
				$stack = func_get_arg(1);
			} else {
				$stack = new \ArrayObject();
			}

			if (func_num_args() > 2) {
				$reader = func_get_arg(2);
			} else {
				$reader = new AnnotationReader();
			}

			if (func_num_args() > 3) {
				$phpParser = func_get_arg(3);
			} else {
				$phpParser = new PhpParser();
			}

			if (func_num_args() > 4 && func_get_arg(4) !== null) {
				/** @var Type $declaringType */
				$declaringType = func_get_arg(4);
				$useStatements = $declaringType->getUseStatements();
			} else {
				$declaringType = null;
				$useStatements = array();
			}

			if ($lowercaseString === "\$this" || $lowercaseString === "self" || $lowercaseString === "static") {
				if ($declaringType === null) {
					throw new \InvalidArgumentException("Type string references declaring class, but no declaring class given.");
				}

				return $declaringType;

			} elseif (substr($string, -2) === "[]") {
				$baseString = substr($string, 0, strlen($string) - 2);
				return ArrayType::create(MixedType::fromString($baseString, $stack, $reader, $phpParser, $declaringType));

			} else {
				if ($string[0] === "\\") {
					$typeName = trim($string, "\\");

				} elseif (isset($useStatements[$lowercaseString])) {
					$typeName = $useStatements[$lowercaseString];
					// TODO: `use` with namespace (e.g. `use Doctrine\Mapping as ORM;`)

				} elseif ($declaringType !== null) {
					$typeName = $declaringType->getNamespaceName() . "\\" . $string;

				} else {
					$typeName = $string;
				}

				return Type::fromReflection(new \ReflectionClass($typeName), $stack, $reader, $phpParser);
			}
		}
	}
718639
public static function unique($string)
	{
		//set intitial unique var sting as empty
		$unique = '';

		//split the string into substrings
		$parts = str_split($string);

		//loop through the sting parts array removing duplicated characters
		foreach ($parts as $part) 
		{
			//add this character if it doesnt exist yet
			if( ! strstr($unique, $part) )
			{
				//add this character to the main unique array
				$unique .= $part;

			}

		}

		//return the unique string
		return $unique;

	}
8348
public function getString($string)
    {
        // Exact match?
        if (isset($this->strings[$string])) {
            return $this->strings[$string];
        } else {
            return $string;
        }
    }