public function test_str_before()
 {
     $string = Str::before('*****@*****.**', '@');
     $this->assertEquals('user', $string);
     $string = Str::before('user@example@.org', '@');
     $this->assertEquals('user', $string);
     $string = Str::before('userexample.org', '@');
     $this->assertEquals('userexample.org', $string);
     $string = Str::before('', '@');
     $this->assertEquals('', $string);
 }
if (!Str::hasMacro('tease')) {
    /**
     * Shortens a string in a pretty way. Removes all double spaces and HTML.
     * The string is concatenated with the moreTextIndicator.
     *
     * @param string $string
     * @param int    $length
     * @param string $moreTextIndicator
     * @return string
     */
    Str::macro('tease', function ($string, $length = 200, $moreTextIndicator = '...') {
        $string = preg_replace("/\\s+/", ' ', strip_tags(trim($string)));
        if (strlen($string) <= $length) {
            return $string;
        }
        return Str::before(wordwrap($string, $length, "\n"), "\n") . $moreTextIndicator;
    });
}
if (!Str::hasMacro('segment')) {
    /**
     * Get a segment of a string based on a delimiter.
     * Use a negative index to start counting from the last element.
     *
     * @param string $string
     * @param string $delimiter
     * @param int    $nth
     * @return string
     */
    Str::macro('segment', function ($string, $delimiter, $nth) {
        $segments = explode($delimiter, $string);
        if ($nth < 0) {
 /**
  * Get the part of haystack before needle.
  *
  * @param string $haystack
  * @param string $needle
  * @return string
  */
 function str_before($haystack, $needle)
 {
     return Str::before($haystack, $needle);
 }