StateDiagram Class

class StateDiagram

Represents a state diagram

addClassDef(array $classDef)

Add class definition(s)

Parameters:
  • $classDef (array) – The class definition(s)

Returns:

A new instance of StateDiagram with the class definition(s) added

Return type:

StateDiagram

addState(StateInterface ...$state)

Adds state(s)

Parameters:
Returns:

A new instance of StateDiagram with the state(s) added

Return type:

StateDiagram

addTransition(Transition ...$transition)

Adds transition(s)

Parameters:
  • ...$transition (Transition) – The transition(s)

Returns:

A new instance of StateDiagram with the transition(s) added

Return type:

StateDiagram

render(array $attributes = [])

Renders the diagram

Parameters:
  • $attributes (array) –

    HTML attributes for the <pre> tag as name=>value pairs

    Note

    The mermaid class is added

Returns:

Mermaid diagram code in a <pre> tag

Return type:

string

withClassDef(array $classDef)

Set class definition(s)

Parameters:
  • $classDef (array) – The class definition(s)

Returns:

A new instance of StateDiagram with the class definition(s)

Return type:

StateDiagram

withComment(string $comment)

Set a comment

Parameters:
  • $comment (string) – The comment

Returns:

A new instance of StateDiagram with a comment

Return type:

StateDiagram

withDirection(Direction $direction)

Set the diagram direction

Parameters:
Returns:

A new instance of StateDiagram with the direction set

Return type:

StateDiagram

withState(StateInterface ...$state)

Set state(s)

Parameters:
Returns:

A new instance of StateDiagram with the state(s)

Return type:

StateDiagram

withTransition(Transition ...$transition)

Sets transition(s)

Parameters:
  • ...$transition (Transition) – The transition(s)

Returns:

A new instance of StateDiagram with the transition(s)

Return type:

StateDiagram