static function Shorten($str, $length = 32, $respectWords = false, $noEllipsis = false, $forceEllipsis = false, $entityDecode = false)
    {
        if ($entityDecode)
            $str = html_entity_decode($str, ENT_COMPAT, 'utf-8');

        $str = Str::Trim(strip_tags($str));
        
        if (strlen ($str) <= $length)
	{
	  if ($forceEllipsis)
	    return self::CorrectSpaces($str) . "...";
	  
          else
	    return self::CorrectSpaces($str);
	}

        $str = mb_substr($str, 0, $length - 3, 'utf-8');
        if ($respectWords)
	{
            $pos = mb_strrpos($str, " ", -1, 'utf-8');
            if ($pos > $length / 2)
                $str = mb_substr($str, 0, $pos, 'utf-8');
        }
        $str = self::CorrectSpaces($str);
        
        if (!$noEllipsis)
            $str = $str . "...";
        
        return $str;
    }
static function Shorten($str, $length = 32, $respectWords = false, $noEllipsis = false, $forceEllipsis = false, $entityDecode = false)
    {
        if ($entityDecode)
            $str = html_entity_decode($str, ENT_COMPAT, 'utf-8');

        $str = Str::Trim(strip_tags($str));
        
        if (strlen ($str) <= $length)
	{
	  if ($forceEllipsis)
	    return self::CorrectSpaces($str) . "...";
	  
          else
	    return self::CorrectSpaces($str);
	}

        $str = mb_substr($str, 0, $length - 3, 'utf-8');
        if ($respectWords)
	{
            $pos = mb_strrpos($str, " ", -1, 'utf-8');
            if ($pos > $length / 2)
                $str = mb_substr($str, 0, $pos, 'utf-8');
        }
        $str = self::CorrectSpaces($str);
        
        if (!$noEllipsis)
            $str = $str . "...";
        
        return $str;
    }
static function Shorten ( $ str , $ length = 32 , $ respectWords = false , $ noEllipsis = false , $ forceEllipsis = false , $ entityDecode = false ) { if ( $ entityDecode ) $ str = html_entity_decode ( $ str , ENT_COMPAT , 'utf-8' ) ; $ str = Str :: Trim ( strip_tags ( $ str ) ) ; if ( strlen ( $ str ) <= $ length ) { if ( $ forceEllipsis ) return self :: CorrectSpaces ( $ str ) . "..." ; else return self :: CorrectSpaces ( $ str ) ; } $ str = mb_substr ( $ str , 0 , $ length - 3 , 'utf-8' ) ; if ( $ respectWords ) { $ pos = mb_strrpos ( $ str , " " , - 1 , 'utf-8' ) ; if ( $ pos > $ length / 2 ) $ str = mb_substr ( $ str , 0 , $ pos , 'utf-8' ) ; } $ str = self :: CorrectSpaces ( $ str ) ; if ( ! $ noEllipsis ) $ str = $ str . "..." ; return $ str ; }
Cuts off text of desired length
@param string $str Input tect
@param int $length Desired length
@param bool $respectWords Set true so no words are broken
@param bool $noEllipsis true if no ellipsis shall be added
@param bool $forceEllipsis True if ellipsis shall be added even if text is shorter then desired
@param bool $entityDecode True if an entity decode shall be performed
@return string
Cuts off text of desired length