Symfony\Component\Console\Descriptor\TextDescriptor::calculateTotalWidthForOptions PHP Method

calculateTotalWidthForOptions() private method

private calculateTotalWidthForOptions ( Symfony\Component\Console\Input\InputOption[] $options ) : integer
$options Symfony\Component\Console\Input\InputOption[]
return integer
    private function calculateTotalWidthForOptions($options)
    {
        $totalWidth = 0;
        foreach ($options as $option) {
            // "-" + shortcut + ", --" + name
            $nameLength = 1 + max(strlen($option->getShortcut()), 1) + 4 + strlen($option->getName());
            if ($option->acceptValue()) {
                $valueLength = 1 + strlen($option->getName());
                // = + value
                $valueLength += $option->isValueOptional() ? 2 : 0;
                // [ + ]
                $nameLength += $valueLength;
            }
            $totalWidth = max($totalWidth, $nameLength);
        }
        return $totalWidth;
    }