Convert a string to camel-case.

@return object|Manipulator
179384
public function toCamelCase() : Manipulator
    {
        $modifiedString = '';

        foreach (explode(' ', $this->string) as $word) {
            $modifiedString .= self::make($word)->toLower()->capitalize()->toString();
        }

        $final = self::make($modifiedString)
            ->replace(' ', '')
            ->lowercaseFirst()
            ->toString();

        return new static($final);
    }
729433
def class_case(string):
    
    if not string:
        return string
    string = string.replace(' ', '_').replace('-', '_')
    parts = de_camel(string, '_', _lowercase=False).split('_')
    rv = ''
    while parts:
        part = parts.pop(0)
        rv += part.title() or '_'
        if part:
            break
    return rv + ''.join([part if part.isupper() else part.title()
                         for part in parts])
1142603
public static function camelCaseToSnakeCase($value): string
    {
        $value = ToString::toString($value);
        $parts = \preg_split('~([[:upper:]][[:lower:]]+|[^[:upper:]]*[[:lower:]]+)~u', $value, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
        $underscored = \preg_replace('~_{2,}~', '_', \implode('_', $parts));

        return \strtolower($underscored);
    }
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);
			}
		}
	}
28015
public function toSnakeCase()
    {
        $snake = UTF8::normalize_whitespace($this->scalarString);

        $snake = str_replace('-', '_', $snake);

        $snake = preg_replace_callback
        (
            '/([\d|A-Z])/u',
            function ($matches)
            {
                $match = $matches[1];
                $matchInt = (int)$match;

                if ("$matchInt" == $match)
                {
                    return '_' . $match . '_';
                }
                else
                {
                    return '_' . UTF8::strtolower($match, $this->encoding);
                }
            },
            $snake
        );

        $snake = preg_replace
        (
            [
                '/\s+/',        // convert spaces to "_"
                '/^\s+|\s+$/',  // trim leading & trailing spaces
                '/_+/'          // remove double "_"
            ],
            [
                '_',
                '',
                '_'
            ],
            $snake
        );

        // trim leading & trailing "_"
        $snake = UTF8::trim($snake, '_');

        // trim leading & trailing whitespace
        $snake = UTF8::trim($snake);

        return $this->newSelf($snake);
    }
241135
static function camelize($str) {
        // john_aldrich -> john aldrich
        $str = str_replace('_', ' ', $str);

        // john aldrich -> John Aldrich
        $str = ucwords($str);

        // John Aldrich -> JohnAldrich
        $str = str_replace(' ', '', $str);

        return lcfirst($str);
    }
42360
public static function camelCase($value)
    {
        if (isset(static::$camelCache[$value])) {
            return static::$camelCache[$value];
        }

        return static::$camelCache[$value] = lcfirst(static::pascalCase($value));
    }
1162419
public static function toCamelCase($name, $Pascal = false) {
        $p = $Pascal ? 't' : 'f';
        if (!isset(self::$camelCase[$p][$name])) {
            $r = self::extractWords($name);
            $r = ucwords($r);
            if (!$Pascal) {
                $r = lcfirst($r);
            }
            $r = strtr($r, array(' ' => ''));
            self::$camelCase[$p][$name] = $r;
        }
        return self::$camelCase[$p][$name];
    }
1069477
def camelize(string, lower = false)
      string = string.to_s.gsub(/(?:^|_)(.)/) { Regexp.last_match(1).upcase }
      string = string[0].chr.downcase + string[1..-1] if lower
      string
    end
202442
def convert_camel_case_string(name: str) -> str:
    """"""
    string = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", name)
    return re.sub("([a-z0-9])([A-Z])", r"\1_\2", string).lower()
761543
public function camelize() {
        $encoding = $this->encoding;
        $stringy = self::create($this->str, $this->encoding);

        $camelCase = preg_replace_callback(
                '/[-_\s]+(.)?/u', function ($match) use (&$encoding) {
            return $match[1] ? mb_strtoupper($match[1], $encoding) : "";
        }, $stringy->trim()->lowerCaseFirst()->str
        );

        $stringy->str = preg_replace_callback(
                '/[\d]+(.)?/u', function ($match) use (&$encoding) {
            return mb_strtoupper($match[0], $encoding);
        }, $camelCase
        );

        return $stringy;
    }
1228263
public function splitCamelCase() {
        preg_match_all('/((?:^|[\p{Lu}])[\p{Ll}_]+)/mu', $this->string, $matches);
        $returnValue = implode(' ', $matches[0]);

        return $this->createClone($returnValue);
    }
1059221
public static function camel2case($string, $delimiter = '_')
    {
        return ltrim(preg_replace_callback('/[A-Z]/', function ($mathes) use ($delimiter) {
            return $delimiter . strtolower($mathes[0]);
        }, $string), $delimiter);
    }
1126692
static function CamelCase($string) {
		$string = preg_replace_callback('#([_])(\w)#', function ($m) {
			return strtoupper($m[2]);
		}, strtolower($string));

		return ucfirst($string);
	}
1029927
public static function camelTo_($str) {
        if (!is_string($str))
            return '';
        $str[0] = strtolower($str[0]);
        $func = create_function('$c', 'return "_" . strtolower($c[1]);');
        return preg_replace_callback('/([A-Z])/', $func, $str);
    }
1325858
public function toPascalCase(): Utility
    {
        $string = ucfirst($this->toCamelCase()->value());

        return new static($string, $this->encoding);
    }
267625
protected function convertCase($request)
    {
        $inflector = new Inflector();
        switch ($this->defaultCaseFormat) {
            // assume camel case and should convert to snake
            case "snake":
                if (is_object($request)) {
                    $request = $inflector->objectPropertiesToSnake($request);
                } elseif (is_array($request)) {
                    $request = $inflector->arrayKeysToSnake($request);
                }

                break;

            // assume snake and should convert to camel
            case "camel":
                if (is_object($request)) {
                    $request = $inflector->objectPropertiesToCamel($request);
                } elseif (is_array($request)) {
                    $request = $inflector->arrayKeysToCamel($request);
                }
                break;
            default:
                break;
        }
        return $request;
    }