protected function processPhixSwitchesAfterCommandLoad(Context $context, ParsedSwitches $ParsedSwitches) { // what switches do we have? $parsedSwitches = $ParsedSwitches->getSwitches(); // let's deal with them foreach ($parsedSwitches as $parsedSwitch) { $switchName = $parsedSwitch->name; $className = '\\Phix_Project\\PhixSwitches\\' . ucfirst($switchName) . 'Switch'; $errCode = $className::processAfterCommandLoad($context, $ParsedSwitches->getArgsForSwitch($switchName)); if ($errCode !== null) { return $errCode; } } // all done - return NULL to signify that we're not yet // ready to terminate phix return null; }
public function testCanAddRepeatedSwitchesWithArguments() { // define the options we are expecting $expectedOptions = new DefinedSwitches(); // create the switch to add $switchName = 'fred'; $switchDesc = 'trout'; $expectedOptions->addSwitch($switchName, $switchDesc); $args = array('hickory', 'dickory', 'dock', 'the', 'mouse', 'ran', 'up', 'the', 'clock'); // add the switch $ParsedSwitches = new ParsedSwitches(); foreach ($args as $arg) { $ParsedSwitches->addSwitch($expectedOptions, $switchName, $arg); } // did it work? $switches = $ParsedSwitches->getSwitches(); $this->assertEquals(1, count($switches)); $this->assertEquals($switchName, $switches[$switchName]->name); $this->assertEquals(count($args), count($ParsedSwitches->getArgsForSwitch($switchName))); $this->assertEquals(count($args), $ParsedSwitches->getInvokeCountForSwitch($switchName)); $this->assertEquals($args, $ParsedSwitches->getArgsForSwitch($switchName)); }