public function toShorten($length = 32, $truncate = false)
        {
            $string = $this->get();

            if (is_bool($length)) {
                $truncate = $length;
                $length = 32;
            } else {
                $length = (int)$length;
            }

            if (strlen($string) > $length) {
                $length - 4;
                $string = substr($string, 0, $length);
                if (!$truncate) {
                    $string = explode(' ', $string);
                    $size = count($string) - 1;
                    if ($size > -1) {
                        $final = '';
                        for ($i = 0; $i < $size; ++$i) {
                            $final .= $string[$i].' ';
                        }
                        $string = $final;
                    }
                }
                $string = trim($string).'...';
            }

            return $string;
        }
public function toShorten($length = 32, $truncate = false)
        {
            $string = $this->get();

            if (is_bool($length)) {
                $truncate = $length;
                $length = 32;
            } else {
                $length = (int)$length;
            }

            if (strlen($string) > $length) {
                $length - 4;
                $string = substr($string, 0, $length);
                if (!$truncate) {
                    $string = explode(' ', $string);
                    $size = count($string) - 1;
                    if ($size > -1) {
                        $final = '';
                        for ($i = 0; $i < $size; ++$i) {
                            $final .= $string[$i].' ';
                        }
                        $string = $final;
                    }
                }
                $string = trim($string).'...';
            }

            return $string;
        }
public function toShorten ( $ length = 32 , $ truncate = false ) { $ string = $ this -> get ( ) ; if ( is_bool ( $ length ) ) { $ truncate = $ length ; $ length = 32 ; } else { $ length = ( int ) $ length ; } if ( strlen ( $ string ) > $ length ) { $ length - 4 ; $ string = substr ( $ string , 0 , $ length ) ; if ( ! $ truncate ) { $ string = explode ( ' ' , $ string ) ; $ size = count ( $ string ) - 1 ; if ( $ size > - 1 ) { $ final = '' ; for ( $ i = 0 ; $ i < $ size ; ++ $ i ) { $ final .= $ string [ $ i ] . ' ' ; } $ string = $ final ; } } $ string = trim ( $ string ) . '...' ; } return $ string ; }
Shorten a string.

@param int $length
@param bool $truncate
@return string
Shorten a string .