/** * Add Option Definition * * @param OptionDefinition $optionDefinition * * @return void */ public function add(OptionDefinition $optionDefinition) { $this->options[$optionDefinition->getLabel()] = $optionDefinition; if (($shortName = $optionDefinition->getShortName()) !== null) { $this->map[$shortName] = $optionDefinition; } if (($longName = $optionDefinition->getLongName()) !== null) { $this->map[$longName] = $optionDefinition; } }
/** * @inheritDoc */ public function __toString() { $names = []; if (($longName = $this->optionDefinition->getLongName()) !== null) { $names[] = $longName; } if (($shortName = $this->optionDefinition->getShortName()) !== null) { $names[] = $shortName; } return 'option(' . implode(' | ', $names) . ')::' . $this->optionDefinition->getType(); }
public function hasOption(OptionDefinition $definition) { return isset($this->options[$definition->getLabel()]); }