GetOptionKit\Option::__toString PHP Method

__toString() public method

public __toString ( )
    public function __toString()
    {
        $c1 = $this->renderReadableSpec();
        $return = '';
        $return .= sprintf('* key:%-8s spec:%s  desc:%s', $this->getId(), $c1, $this->desc) . "\n";
        $val = $this->getValue();
        if (is_array($val)) {
            $return .= '  value => ' . join(',', array_map(function ($v) {
                return var_export($v, true);
            }, $val)) . "\n";
        } else {
            $return .= sprintf('  value => %s', $val) . "\n";
        }
        return $return;
    }

Usage Example

コード例 #1
0
ファイル: OptionTest.php プロジェクト: c9s/getoptionkit
 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());
 }