private static function descriptionTrimmer(
        string $description,
        int $desciptionCharStart,
        int $descriptionLength
    ) {
        $remainder = $description;

        $firstLine = true;

        while (strlen($remainder) > 0)
        {
            $space = '';

            if ( ! $firstLine)
            {
                $space = str_repeat(' ', $desciptionCharStart);
            }

            if (($len = strlen($remainder)) > $descriptionLength)
            {
                if (
                    ($n = strrpos(
                        $remainder,
                        ' ',
                        $descriptionLength - $len
                    )) !== false
                ) {
                    $piece = substr($remainder, 0, $n);

                    # plus one to remove leading space
                    $remainder = substr($remainder, $n + 1);
                }
                else
                {
                    $piece = substr($remainder, 0, $descriptionLength);

                    $remainder = substr($remainder, $descriptionLength);
                }
            }
            else
            {
                $piece = $remainder;

                $remainder = '';
            }

            yield $space.$piece;

            $firstLine = false;
        }
    }
private static function descriptionTrimmer(
        string $description,
        int $desciptionCharStart,
        int $descriptionLength
    ) {
        $remainder = $description;

        $firstLine = true;

        while (strlen($remainder) > 0)
        {
            $space = '';

            if ( ! $firstLine)
            {
                $space = str_repeat(' ', $desciptionCharStart);
            }

            if (($len = strlen($remainder)) > $descriptionLength)
            {
                if (
                    ($n = strrpos(
                        $remainder,
                        ' ',
                        $descriptionLength - $len
                    )) !== false
                ) {
                    $piece = substr($remainder, 0, $n);

                    # plus one to remove leading space
                    $remainder = substr($remainder, $n + 1);
                }
                else
                {
                    $piece = substr($remainder, 0, $descriptionLength);

                    $remainder = substr($remainder, $descriptionLength);
                }
            }
            else
            {
                $piece = $remainder;

                $remainder = '';
            }

            yield $space.$piece;

            $firstLine = false;
        }
    }
private static function descriptionTrimmer ( string $ description , int $ desciptionCharStart , int $ descriptionLength ) { $ remainder = $ description ; $ firstLine = true ; while ( strlen ( $ remainder ) > 0 ) { $ space = '' ; if ( ! $ firstLine ) { $ space = str_repeat ( ' ' , $ desciptionCharStart ) ; } if ( ( $ len = strlen ( $ remainder ) ) > $ descriptionLength ) { if ( ( $ n = strrpos ( $ remainder , ' ' , $ descriptionLength - $ len ) ) !== false ) { $ piece = substr ( $ remainder , 0 , $ n ) ; # plus one to remove leading space $ remainder = substr ( $ remainder , $ n + 1 ) ; } else { $ piece = substr ( $ remainder , 0 , $ descriptionLength ) ; $ remainder = substr ( $ remainder , $ descriptionLength ) ; } } else { $ piece = $ remainder ; $ remainder = '' ; } yield $ space . $ piece ; $ firstLine = false ; } }
Load options from a .json file

@param string $description
the description to trim
@param string $desciptionCharStart
the number of chars past a newline that the description column starts
@param int $descriptionLength
the hard-wrap length of the description

@return \Generator|string[]
yields a single line until the given description text is exhausted
Load options from a . json file