public static function substrToString($haystack, $needle, $case_sensitive = true)
    {
        $compare_func = $case_sensitive ? 'mb_strpos' : 'mb_stripos';

        if (static::contains($haystack, $needle, $case_sensitive)) {
            return mb_substr($haystack, 0, $compare_func($haystack, $needle, $case_sensitive));
        }

        return $haystack;
    }
public static function substrToString($haystack, $needle, $case_sensitive = true)
    {
        $compare_func = $case_sensitive ? 'mb_strpos' : 'mb_stripos';

        if (static::contains($haystack, $needle, $case_sensitive)) {
            return mb_substr($haystack, 0, $compare_func($haystack, $needle, $case_sensitive));
        }

        return $haystack;
    }
public static function substrToString ( $ haystack , $ needle , $ case_sensitive = true ) { $ compare_func = $ case_sensitive ? 'mb_strpos' : 'mb_stripos' ; if ( static :: contains ( $ haystack , $ needle , $ case_sensitive ) ) { return mb_substr ( $ haystack , 0 , $ compare_func ( $ haystack , $ needle , $ case_sensitive ) ) ; } return $ haystack ; }
Returns the substring of a string up to a specified needle.  if not found, return the whole haystack

@param string $haystack
@param string $needle
@param bool $case_sensitive

@return string
Returns the substring of a string up to a specified needle . if not found return the whole haystack