private function switchToNewStates(array $newStateList): AutomatedInterface
    {
        $this->filterStatesNames($newStateList);

        $lastEnabledStates = $this->listEnabledStates();

        $outgoingStates = \array_diff($lastEnabledStates, $newStateList);
        foreach ($outgoingStates as $stateName) {
            //disable older states
            $this->disableState($stateName);
        }

        $incomingStates = \array_diff($newStateList, $lastEnabledStates);
        foreach ($incomingStates as $stateName) {
            //enable missing states
            $this->enableState($stateName);
        }

        return $this;
    }
private function switchToNewStates(array $newStateList): AutomatedInterface
    {
        $this->filterStatesNames($newStateList);

        $lastEnabledStates = $this->listEnabledStates();

        $outgoingStates = \array_diff($lastEnabledStates, $newStateList);
        foreach ($outgoingStates as $stateName) {
            //disable older states
            $this->disableState($stateName);
        }

        $incomingStates = \array_diff($newStateList, $lastEnabledStates);
        foreach ($incomingStates as $stateName) {
            //enable missing states
            $this->enableState($stateName);
        }

        return $this;
    }
private function switchToNewStates ( array $ newStateList ) : AutomatedInterface { $ this -> filterStatesNames ( $ newStateList ) ; $ lastEnabledStates = $ this -> listEnabledStates ( ) ; $ outgoingStates = \ array_diff ( $ lastEnabledStates , $ newStateList ) ; foreach ( $ outgoingStates as $ stateName ) { //disable older states $ this -> disableState ( $ stateName ) ; } $ incomingStates = \ array_diff ( $ newStateList , $ lastEnabledStates ) ; foreach ( $ incomingStates as $ stateName ) { //enable missing states $ this -> enableState ( $ stateName ) ; } return $ this ; }
To enable and disable states according validations rules.

@param string[] $newStateList

@return AutomatedInterface
To enable and disable states according validations rules .