public function handle($filePath, $results)
    {
        $responseCollection = new PredefinedResponseCollection();
        $responseCollection->append(
            new PredefinedResponse('postpone', 'postpone', self::POSTPONE)
        );
        $responseCollection->append(
            new PredefinedResponse('show diff', 'show diff', self::SHOW_DIFF)
        );
        $responseCollection->append(
            new PredefinedResponse('erase', 'erase', self::ERASE)
        );
        $responseCollection->append(
            new PredefinedResponse('cancel', 'cancel', self::CANCEL)
        );

        $question = new QuestionWithPredefinedResponse(
            sprintf('File "%s" already exist, erase it with the new', $filePath),
            'conflict' . $filePath,
            $responseCollection
        );

        $question->setShutdownWithoutResponse(true, sprintf('Conflict with file "%s" not resolved', $filePath));

        while (($response = $this->context->askCollection($question)) !== null) {
            $response = intval($response);

            if ($response === self::SHOW_DIFF) {
                // write to output the diff
                $this->context->log(
                    '<info>' . $this->diffPHP->diff($results, $this->fileManager->fileGetContent($filePath)) . '</info>'
                );
            } else {
                break;
            }
        }

        if ($response === self::POSTPONE) {
            //Generate the diff file
            $this->fileManager->filePutsContent(
                $filePath . '.diff',
                $this->diffPHP->diff(
                    $results,
                    $this->fileManager->fileGetContent($filePath)
                )
            );
            $this->context->log('--> Generate diff and new file ' . $filePath . '.diff', 'generationLog');
        } elseif ($response === self::ERASE) {
            $this->fileManager->filePutsContent($filePath, $results);
            $this->context->log('--> Replace file ' . $filePath, 'generationLog');
        }
    }
public function handle($filePath, $results)
    {
        $responseCollection = new PredefinedResponseCollection();
        $responseCollection->append(
            new PredefinedResponse('postpone', 'postpone', self::POSTPONE)
        );
        $responseCollection->append(
            new PredefinedResponse('show diff', 'show diff', self::SHOW_DIFF)
        );
        $responseCollection->append(
            new PredefinedResponse('erase', 'erase', self::ERASE)
        );
        $responseCollection->append(
            new PredefinedResponse('cancel', 'cancel', self::CANCEL)
        );

        $question = new QuestionWithPredefinedResponse(
            sprintf('File "%s" already exist, erase it with the new', $filePath),
            'conflict' . $filePath,
            $responseCollection
        );

        $question->setShutdownWithoutResponse(true, sprintf('Conflict with file "%s" not resolved', $filePath));

        while (($response = $this->context->askCollection($question)) !== null) {
            $response = intval($response);

            if ($response === self::SHOW_DIFF) {
                // write to output the diff
                $this->context->log(
                    '<info>' . $this->diffPHP->diff($results, $this->fileManager->fileGetContent($filePath)) . '</info>'
                );
            } else {
                break;
            }
        }

        if ($response === self::POSTPONE) {
            //Generate the diff file
            $this->fileManager->filePutsContent(
                $filePath . '.diff',
                $this->diffPHP->diff(
                    $results,
                    $this->fileManager->fileGetContent($filePath)
                )
            );
            $this->context->log('--> Generate diff and new file ' . $filePath . '.diff', 'generationLog');
        } elseif ($response === self::ERASE) {
            $this->fileManager->filePutsContent($filePath, $results);
            $this->context->log('--> Replace file ' . $filePath, 'generationLog');
        }
    }
public function handle ( $ filePath , $ results ) { $ responseCollection = new PredefinedResponseCollection ( ) ; $ responseCollection -> append ( new PredefinedResponse ( 'postpone' , 'postpone' , self :: POSTPONE ) ) ; $ responseCollection -> append ( new PredefinedResponse ( 'show diff' , 'show diff' , self :: SHOW_DIFF ) ) ; $ responseCollection -> append ( new PredefinedResponse ( 'erase' , 'erase' , self :: ERASE ) ) ; $ responseCollection -> append ( new PredefinedResponse ( 'cancel' , 'cancel' , self :: CANCEL ) ) ; $ question = new QuestionWithPredefinedResponse ( sprintf ( 'File "%s" already exist, erase it with the new' , $ filePath ) , 'conflict' . $ filePath , $ responseCollection ) ; $ question -> setShutdownWithoutResponse ( true , sprintf ( 'Conflict with file "%s" not resolved' , $ filePath ) ) ; while ( ( $ response = $ this -> context -> askCollection ( $ question ) ) !== null ) { $ response = intval ( $ response ) ; if ( $ response === self :: SHOW_DIFF ) { // write to output the diff $ this -> context -> log ( '<info>' . $ this -> diffPHP -> diff ( $ results , $ this -> fileManager -> fileGetContent ( $ filePath ) ) . '</info>' ) ; } else { break ; } } if ( $ response === self :: POSTPONE ) { //Generate the diff file $ this -> fileManager -> filePutsContent ( $ filePath . '.diff' , $ this -> diffPHP -> diff ( $ results , $ this -> fileManager -> fileGetContent ( $ filePath ) ) ) ; $ this -> context -> log ( '--> Generate diff and new file ' . $ filePath . '.diff' , 'generationLog' ) ; } elseif ( $ response === self :: ERASE ) { $ this -> fileManager -> filePutsContent ( $ filePath , $ results ) ; $ this -> context -> log ( '--> Replace file ' . $ filePath , 'generationLog' ) ; } }
Handle the file conflict

@param  string                    $filePath
@param  string                    $results
@throws ResponseExpectedException
Handle the file conflict