public function compile()
    {
        $nodesVisited = [];

        /**
         * Checking the configuration.
         */
        $this
            ->checkTransitionsConfiguration($this->configuration)
            ->checkPointOfEntry(
                $this->configuration,
                $this->pointOfEntry
            )
            ->checkCycles(
                $this->configuration,
                $this->pointOfEntry,
                $nodesVisited
            );

        /**
         * Once checked we compile the structure.
         */
        $this->transitionChain = $this->compileTransitions($this->configuration);

        /**
         * We check the compilation.
         */
        $this
            ->checkTransitionDuplicates($this->transitionChain)
            ->checkStates($this->transitionChain);

        $machine = $this
            ->machineFactory
            ->generate(
                $this->machineId,
                $this->transitionChain,
                $this->pointOfEntry
            );

        return $machine;
    }