PHP Class Webmozart\Console\Api\Formatter\StyleSet

Since: 1.0
Author: Bernhard Schussek ([email protected])
Show file Open project: webmozart/console Class Usage Examples

Public Methods

Method Description
__construct ( array $styles = [] ) Creates a new style set.
add ( Style $style ) Adds a style.
clear ( ) Clears the contents of the style set.
contains ( string $tag ) : boolean Returns whether the style with the given tag exists.
get ( string $tag ) : Style Returns the style with the given tag.
isEmpty ( ) : boolean Returns whether the style set is empty.
merge ( array $styles ) Adds styles to the style set.
remove ( string $tag ) Removes a style.
replace ( array $styles ) Sets the styles of the style set.
toArray ( ) : Style[] Returns all styles.

Method Details

__construct() public method

Creates a new style set.
public __construct ( array $styles = [] )
$styles array The styles to add.

add() public method

Adds a style.
public add ( Style $style )
$style Style The style to add.

clear() public method

Clears the contents of the style set.
public clear ( )

contains() public method

Returns whether the style with the given tag exists.
public contains ( string $tag ) : boolean
$tag string The tag of the style.
return boolean Returns `true` if a style with the given tag exists and `false` otherwise.

get() public method

Returns the style with the given tag.
public get ( string $tag ) : Style
$tag string The tag of the style.
return Style The style.

isEmpty() public method

Returns whether the style set is empty.
public isEmpty ( ) : boolean
return boolean Returns `true` if the set contains no styles and `false` otherwise.

merge() public method

Existing styles are preserved.
public merge ( array $styles )
$styles array The styles to add.

remove() public method

This method does nothing if the tag does not exist.
public remove ( string $tag )
$tag string The tag of the style.

replace() public method

Existing styles are removed.
public replace ( array $styles )
$styles array The styles to set.

toArray() public method

Returns all styles.
public toArray ( ) : Style[]
return Style[] The styles indexed by their tags.