GetOptionKit\Option::renderReadableSpec PHP Method

renderReadableSpec() public method

get readable spec for printing.
public renderReadableSpec ( string $renderHint = true )
$renderHint string render also value hint
    public function renderReadableSpec($renderHint = true)
    {
        $c1 = '';
        if ($this->short && $this->long) {
            $c1 = sprintf('-%s, --%s', $this->short, $this->long);
        } else {
            if ($this->short) {
                $c1 = sprintf('-%s', $this->short);
            } else {
                if ($this->long) {
                    $c1 = sprintf('--%s', $this->long);
                }
            }
        }
        if ($renderHint) {
            return $c1 . $this->renderValueHint();
        }
        return $c1;
    }

Usage Example

Example #1
0
 public function testValidValues()
 {
     $opt = new Option('scope');
     $opt->validValues(['public', 'private']);
     $this->assertNotEmpty($opt->getValidValues());
     $this->assertTrue(is_array($opt->getValidValues()));
     $opt->setValue('public');
     $opt->setValue('private');
     $this->assertEquals('private', $opt->value);
     $this->assertEquals('--scope=(public,private)', $opt->renderReadableSpec(true));
     $this->assertNotEmpty($opt->__toString());
 }