public static function generate(
        array $options,
        int $descriptionLength
    ) : string
    {
        $lines = array();
        $nameCols = array();

        $maxLineLength = 0;

        # make sure keys are ordered
        $options = array_values($options);

        foreach ($options as $option)
        {
            $line = '  ';

            $line .= $option->getPrintableName();

            $aliases = $option->getAliasNames();

            if ( ! empty($aliases))
            {
                $line .= ', '.implode(', ', $aliases);
            }

            if (($len = strlen($line)) > $maxLineLength)
            {
                $maxLineLength = $len;
            }

            $nameCols[] = $line;
        }

        $desciptionCharStart = $maxLineLength + 4;

        $desciptionCharStart += Math::mod(4 - $desciptionCharStart, 4);

        foreach ($options as $key => $option)
        {
            $line = $nameCols[$key];

            $description = $option->getDescription();

            if (isset($description))
            {
                self::formatLineWithDescription(
                    $line,
                    $description,
                    $desciptionCharStart,
                    $descriptionLength,
                    $lines
                );
            }
            else
            {
                $lines[] = $line;
            }
        }

        $lines[] = '';

        return implode("\n", $lines);
    }
public static function generate(
        array $options,
        int $descriptionLength
    ) : string
    {
        $lines = array();
        $nameCols = array();

        $maxLineLength = 0;

        # make sure keys are ordered
        $options = array_values($options);

        foreach ($options as $option)
        {
            $line = '  ';

            $line .= $option->getPrintableName();

            $aliases = $option->getAliasNames();

            if ( ! empty($aliases))
            {
                $line .= ', '.implode(', ', $aliases);
            }

            if (($len = strlen($line)) > $maxLineLength)
            {
                $maxLineLength = $len;
            }

            $nameCols[] = $line;
        }

        $desciptionCharStart = $maxLineLength + 4;

        $desciptionCharStart += Math::mod(4 - $desciptionCharStart, 4);

        foreach ($options as $key => $option)
        {
            $line = $nameCols[$key];

            $description = $option->getDescription();

            if (isset($description))
            {
                self::formatLineWithDescription(
                    $line,
                    $description,
                    $desciptionCharStart,
                    $descriptionLength,
                    $lines
                );
            }
            else
            {
                $lines[] = $line;
            }
        }

        $lines[] = '';

        return implode("\n", $lines);
    }
public static function generate ( array $ options , int $ descriptionLength ) : string { $ lines = array ( ) ; $ nameCols = array ( ) ; $ maxLineLength = 0 ; # make sure keys are ordered $ options = array_values ( $ options ) ; foreach ( $ options as $ option ) { $ line = '  ' ; $ line .= $ option -> getPrintableName ( ) ; $ aliases = $ option -> getAliasNames ( ) ; if ( ! empty ( $ aliases ) ) { $ line .= ', ' . implode ( ', ' , $ aliases ) ; } if ( ( $ len = strlen ( $ line ) ) > $ maxLineLength ) { $ maxLineLength = $ len ; } $ nameCols [ ] = $ line ; } $ desciptionCharStart = $ maxLineLength + 4 ; $ desciptionCharStart += Math :: mod ( 4 - $ desciptionCharStart , 4 ) ; foreach ( $ options as $ key => $ option ) { $ line = $ nameCols [ $ key ] ; $ description = $ option -> getDescription ( ) ; if ( isset ( $ description ) ) { self :: formatLineWithDescription ( $ line , $ description , $ desciptionCharStart , $ descriptionLength , $ lines ) ; } else { $ lines [ ] = $ line ; } } $ lines [ ] = '' ; return implode ( "\n" , $ lines ) ; }
Generate help text given an array of options

@param Option[] $options

@return string;
Generate help text given an array of options