Skip to content

[doc] add state machine example  #5

@makasim

Description

@makasim

https://twitter.com/maksim_ka2/status/913404270732615680

<?php
    public function can(string $nodeLabel, string $action): bool
    {
        $stateNode = null;
        foreach ($this->process->getNodes() as $node) {
            if ($node->getLabel() === $nodeLabel) {
                $stateNode = $node;
            }
        }

        if (false == $stateNode) {
            throw new \LogicException();
        }

        return (bool) $this->process->getOutTransitionsWithName($stateNode, $action);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions