public function generate(TerminalStateInterface $currentState, TerminalState $desiredState) {

        // get a state object with anything that is changing
        $changes = $currentState->findChanges($desiredState);

        // if an object is returned, then just positive changes are occurring
        if ($changes) {
            
            // if there are really no changes
            if ($changes->isClear()) {

                // return an empty string
                return "";
               
            // there are some changes
            } else {

                // generate the sequence for the things that are actually changing
                return $this->generateSequence($changes, false);

            }


        // if null is returned, then something is getting turned off
        } else {

            // must generate a sequence with a clear
            return $this->generateSequence($desiredState, true);
        }



    }
public function generate(TerminalStateInterface $currentState, TerminalState $desiredState) {

        // get a state object with anything that is changing
        $changes = $currentState->findChanges($desiredState);

        // if an object is returned, then just positive changes are occurring
        if ($changes) {
            
            // if there are really no changes
            if ($changes->isClear()) {

                // return an empty string
                return "";
               
            // there are some changes
            } else {

                // generate the sequence for the things that are actually changing
                return $this->generateSequence($changes, false);

            }


        // if null is returned, then something is getting turned off
        } else {

            // must generate a sequence with a clear
            return $this->generateSequence($desiredState, true);
        }



    }
public function generate ( TerminalStateInterface $ currentState , TerminalState $ desiredState ) { // get a state object with anything that is changing $ changes = $ currentState -> findChanges ( $ desiredState ) ; // if an object is returned, then just positive changes are occurring if ( $ changes ) { // if there are really no changes if ( $ changes -> isClear ( ) ) { // return an empty string return "" ; // there are some changes } else { // generate the sequence for the things that are actually changing return $ this -> generateSequence ( $ changes , false ) ; } // if null is returned, then something is getting turned off } else { // must generate a sequence with a clear return $ this -> generateSequence ( $ desiredState , true ) ; } }
Generate an escape sequence based on the current state and the new desired state

@param TerminalStateInterface $currentState
@param TerminalState $desiredState
@return string
Generate an escape sequence based on the current state and the new desired state