/** * Adds a CLI Named parameter to process. Default values can be specified. * Named parameters in CLI calls MUST have values associated with them. CLI calls can be typically: * -i foobar * -i=foobar * -ifoobar * --identifier foobar * --identifier=foobar * @param string $chrShortIdentifier * @param string $strLongIdentifier * @param QCliParameterType $intCliParameterType * @param mixed $mixDefaultValue * @param string $strHelpText * @return void */ public function AddNamedParameter($chrShortIdentifier, $strLongIdentifier, $intCliParameterType, $mixDefaultValue, $strHelpText) { // Cleanup the Identifiers, and throw in invalid try { $chrShortIdentifier = QCliParameterProcessor::CleanShortIdentifier($chrShortIdentifier); $strLongIdentifier = QCliParameterProcessor::CleanLongIdentifier($strLongIdentifier); } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } // Ensure at least one identifier is requested if (!$chrShortIdentifier && !$strLongIdentifier) { throw new QCallerException('No identifiers were specified'); } // Ensure Identifiers are not already in use if ($chrShortIdentifier && array_key_exists($chrShortIdentifier, $this->chrShortIdentifierArray)) { throw new QCallerException('Short Identifier already in use: ' . $chrShortIdentifier); } if ($strLongIdentifier && array_key_exists($strLongIdentifier, $this->strLongIdentifierArray)) { throw new QCallerException('Long Identifier already in use: ' . $strLongIdentifier); } // Get the ValueIndex for this flag, and set the value to false $intIndex = count($this->mixValueArray); $this->mixValueArray[$intIndex] = $mixDefaultValue; $this->intParameterTypeArray[$intIndex] = $intCliParameterType; $this->strHelpTextArray[$intIndex] = $strHelpText; // Set the Identifiers to this ValueIndex if ($chrShortIdentifier) { $this->chrShortIdentifierArray[$chrShortIdentifier] = $intIndex; $this->chrShortIdentifierByIndex[$intIndex] = $chrShortIdentifier; } if ($strLongIdentifier) { $this->strLongIdentifierArray[$strLongIdentifier] = $intIndex; $this->strLongIdentifierByIndex[$intIndex] = $strLongIdentifier; } }