public static function before(
        string $haystack,
        string $needle,
        bool $useLastNeedle = false
    ): string
    {
        $pos = static::getNeedlePosition($haystack, $needle, $useLastNeedle);
        if ($pos === false) {
            return $haystack;
        }
        return substr($haystack, 0, $pos);
    }
public static function before(
        string $haystack,
        string $needle,
        bool $useLastNeedle = false
    ): string
    {
        $pos = static::getNeedlePosition($haystack, $needle, $useLastNeedle);
        if ($pos === false) {
            return $haystack;
        }
        return substr($haystack, 0, $pos);
    }
public static function before ( string $ haystack , string $ needle , bool $ useLastNeedle = false ) : string { $ pos = static :: getNeedlePosition ( $ haystack , $ needle , $ useLastNeedle ) ; if ( $ pos === false ) { return $ haystack ; } return substr ( $ haystack , 0 , $ pos ) ; }
Get the substring that occurs before another

@param string $haystack The string to search within
@param string $needle The end of the string to return
@return string
Get the substring that occurs before another