By default, this method also includes the default values set for options
with values. You can disable this behavior by passing false for
$includeDefaults.
public getOptions ( boolean $includeDefaults = true ) : array | ||
$includeDefaults | boolean | Whether to return the default values for options that were not set. |
return | array | The option values and `true`/`false` for options without values. |
/** * {@inheritdoc} */ public function getOptions() { return $this->args ? $this->args->getOptions() : array(); }
public function testSetOptions() { $format = ArgsFormat::build()->addOption(new Option('option1', null, Option::NO_VALUE))->addOption(new Option('option2', null, Option::OPTIONAL_VALUE))->addOption(new Option('option3', null, Option::NO_VALUE))->getFormat(); $args = new Args($format); $args->setOption('option1'); $args->setOptions(array('option2' => 'value', 'option3' => true)); $this->assertSame(array('option2' => 'value', 'option3' => true, 'option1' => false), $args->getOptions()); }