src/Util/Str.php
public static function convert($input, $from, $to)
    {
        if (!method_exists(self::class, $to)) {
            return $input;
        }
        
        if (in_array($from, ['camel', 'pascal'])) {
            $converted = self::$from($input);
            $converted = preg_replace('/([a-z])([A-Z])/', '$1 $2', $converted);
            $converted = preg_replace('/(\D)?(\d+)(\D)?/', '$1 $2 $3', $converted);
            return self::$to($converted);
        }
        
        if (method_exists(self::class, $from)) {
            return self::$to(self::$from($input));
        }
        
        return self::$to($input);
    }
public static function convert($input, $from, $to)
    {
        if (!method_exists(self::class, $to)) {
            return $input;
        }
        
        if (in_array($from, ['camel', 'pascal'])) {
            $converted = self::$from($input);
            $converted = preg_replace('/([a-z])([A-Z])/', '$1 $2', $converted);
            $converted = preg_replace('/(\D)?(\d+)(\D)?/', '$1 $2 $3', $converted);
            return self::$to($converted);
        }
        
        if (method_exists(self::class, $from)) {
            return self::$to(self::$from($input));
        }
        
        return self::$to($input);
    }
public static function convert ( $ input , $ from , $ to ) { if ( ! method_exists ( self :: class , $ to ) ) { return $ input ; } if ( in_array ( $ from , [ 'camel' , 'pascal' ] ) ) { $ converted = self :: $ from ( $ input ) ; $ converted = preg_replace ( '/([a-z])([A-Z])/' , '$1 $2' , $ converted ) ; $ converted = preg_replace ( '/(\D)?(\d+)(\D)?/' , '$1 $2 $3' , $ converted ) ; return self :: $ to ( $ converted ) ; } if ( method_exists ( self :: class , $ from ) ) { return self :: $ to ( self :: $ from ( $ input ) ) ; } return self :: $ to ( $ input ) ; }
Convert between two string formats
@param string $input
@param string $from
@param string $to
@return string
Convert between two string formats