public function shorten(): string
    {
        // Shorten only what is longer than the length
        if (strlen($this->string) < $this->length) {
            return $this->string;
        }

        // Shorten string by length
        $this->result = substr($this->string, 0, $this->length);

        // Shorten further until last occurence of a ' '
        $string = substr($this->result, 0, strrpos($this->result, $this->endstring));

        if (!empty($this->wrap_url)) {
            $addition = '<a href="' . $this->wrap_url . '">' . $this->addition . '</a>';
        }

        // Add addition
        $this->result .= $addition;

        // Done.
        return $this->result;
    }
public function shorten(): string
    {
        // Shorten only what is longer than the length
        if (strlen($this->string) < $this->length) {
            return $this->string;
        }

        // Shorten string by length
        $this->result = substr($this->string, 0, $this->length);

        // Shorten further until last occurence of a ' '
        $string = substr($this->result, 0, strrpos($this->result, $this->endstring));

        if (!empty($this->wrap_url)) {
            $addition = '<a href="' . $this->wrap_url . '">' . $this->addition . '</a>';
        }

        // Add addition
        $this->result .= $addition;

        // Done.
        return $this->result;
    }
public function shorten ( ) : string { // Shorten only what is longer than the length if ( strlen ( $ this -> string ) < $ this -> length ) { return $ this -> string ; } // Shorten string by length $ this -> result = substr ( $ this -> string , 0 , $ this -> length ) ; // Shorten further until last occurence of a ' ' $ string = substr ( $ this -> result , 0 , strrpos ( $ this -> result , $ this -> endstring ) ) ; if ( ! empty ( $ this -> wrap_url ) ) { $ addition = '<a href="' . $ this -> wrap_url . '">' . $ this -> addition . '</a>' ; } // Add addition $ this -> result .= $ addition ; // Done. return $ this -> result ; }
Shortens a string to the given length and appends the additional string that can be wrapped by a link when a
wrap url is set.

@return string
Shortens a string to the given length and appends the additional string that can be wrapped by a link when a wrap url is set .