private function checkCycles(
        array $configuration,
        $node,
        array &$nodesVisited
    ) {
        if (in_array($node, $nodesVisited)) {
            if (!$this->canBeCyclic) {
                throw new CyclesNotAllowedException();
            }

            return $this;
        }

        $nodesVisited[] = $node;

        foreach ($configuration as $transitionConfiguration) {
            if ($transitionConfiguration[0] === $node) {
                $this->checkCycles(
                    $configuration,
                    $transitionConfiguration[2],
                    $nodesVisited
                );
            }
        }

        return $this;
    }
private function checkCycles(
        array $configuration,
        $node,
        array &$nodesVisited
    ) {
        if (in_array($node, $nodesVisited)) {
            if (!$this->canBeCyclic) {
                throw new CyclesNotAllowedException();
            }

            return $this;
        }

        $nodesVisited[] = $node;

        foreach ($configuration as $transitionConfiguration) {
            if ($transitionConfiguration[0] === $node) {
                $this->checkCycles(
                    $configuration,
                    $transitionConfiguration[2],
                    $nodesVisited
                );
            }
        }

        return $this;
    }
private function checkCycles ( array $ configuration , $ node , array & $ nodesVisited ) { if ( in_array ( $ node , $ nodesVisited ) ) { if ( ! $ this -> canBeCyclic ) { throw new CyclesNotAllowedException ( ) ; } return $ this ; } $ nodesVisited [ ] = $ node ; foreach ( $ configuration as $ transitionConfiguration ) { if ( $ transitionConfiguration [ 0 ] === $ node ) { $ this -> checkCycles ( $ configuration , $ transitionConfiguration [ 2 ] , $ nodesVisited ) ; } } return $ this ; }
Check cycles.

@param array  $configuration Configuration
@param string $node          Node to check
@param array  $nodesVisited  All visited nodes name

@return $this Self object

@throws CyclesNotAllowedException Cycles found not allowed
Check cycles .