Why does adding a filter to ‘the_title’ break the server?

Here’s the correct code snippet. Hope it’ll work for you.

Helper function

namespace Helpers;
..
function _s_trim_content( $content="", $length = null, $delimiter = null ) {
    $trimmed_content = mb_strimwidth( $content, 
        0, 
        is_null( $length ) ? BIG_INT : $length, 
        '' // Won't use, bugs out.
    );

    if ( mb_strlen( $content ) === mb_strlen( $trimmed_content ) || is_null( $delimiter ) ) {
        $delimiter="";
    }

    return $trimmed_content . $delimiter;
}

the_title filter

add_filter( 'the_title', function( $title, $post_id ) {
    if ( 'post' === get_post_type( $post_id ) ) {
        return \Helpers\_s_trim_content( $title, 24, '...' );
    }
    return $title;
}, 10, 2 );