private function TextDescriptor::calculateTotalWidthForOptions in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/console/Descriptor/TextDescriptor.php \Symfony\Component\Console\Descriptor\TextDescriptor::calculateTotalWidthForOptions()
Parameters
InputOption[] $options:
Return value
int
2 calls to TextDescriptor::calculateTotalWidthForOptions()
- TextDescriptor::describeInputDefinition in vendor/
symfony/ console/ Descriptor/ TextDescriptor.php - Describes an InputDefinition instance.
- TextDescriptor::describeInputOption in vendor/
symfony/ console/ Descriptor/ TextDescriptor.php - Describes an InputOption instance.
File
- vendor/
symfony/ console/ Descriptor/ TextDescriptor.php, line 269
Class
- TextDescriptor
- Text descriptor.
Namespace
Symfony\Component\Console\DescriptorCode
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;
}