Symfony\Component\Console\Formatter\OutputFormatter::getStyle PHP Method

getStyle() public method

Gets style options from style with specified name.
public getStyle ( string $name ) : Symfony\Component\Console\Formatter\OutputFormatterStyleInterface
$name string
return Symfony\Component\Console\Formatter\OutputFormatterStyleInterface
    public function getStyle($name)
    {
        if (!$this->hasStyle($name)) {
            throw new InvalidArgumentException(sprintf('Undefined style: %s', $name));
        }
        return $this->styles[strtolower($name)];
    }

Usage Example

コード例 #1
0
 public function testNewStyle()
 {
     $formatter = new OutputFormatter(true);
     $style = new OutputFormatterStyle('blue', 'white');
     $formatter->setStyle('test', $style);
     $this->assertEquals($style, $formatter->getStyle('test'));
     $this->assertNotEquals($style, $formatter->getStyle('info'));
     $this->assertEquals("some custom msg", $formatter->format('<test>some custom msg</test>'));
 }
All Usage Examples Of Symfony\Component\Console\Formatter\OutputFormatter::getStyle