| Conditions | 7 |
| Paths | 13 |
| Total Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | public function handleConflict(IndexObject $remoteObject, IndexObject $localObject = null, IndexObject $lastLocalObject = null): int |
||
| 29 | { |
||
| 30 | if (!$this->consoleStyle->getInput()->isInteractive()) |
||
| 31 | { |
||
| 32 | throw new Exception(sprintf("Trying to use conflict handler %s with non-interactive input", static::class)); |
||
| 33 | } |
||
| 34 | |||
| 35 | $localObjectString = $localObject ? $localObject->__toString() : '-'; |
||
| 36 | $lastLocalObjectString = $lastLocalObject ? $lastLocalObject->__toString() : '-'; |
||
| 37 | $text = <<<TXT |
||
| 38 | <question>Encountered conflict at {$remoteObject->getRelativePath()} |
||
| 39 | Local: {$localObjectString} |
||
| 40 | Last local: {$lastLocalObjectString} |
||
| 41 | Remote: {$remoteObject}</question> |
||
| 42 | TXT; |
||
| 43 | |||
| 44 | $this->consoleStyle->writeln($text); |
||
| 45 | |||
| 46 | $return = null; |
||
| 47 | do |
||
| 48 | { |
||
| 49 | $choice = $this->consoleStyle->choice('Would you like to use the local (l) or the remote (r) version?', ['l', 'r']); |
||
| 50 | |||
| 51 | switch ($choice) |
||
| 52 | { |
||
| 53 | case 'l': $return = ConflictHandlerInterface::USE_LOCAL; break 2; |
||
| 54 | case 'r': $return = ConflictHandlerInterface::USE_REMOTE; break 2; |
||
| 55 | } |
||
| 56 | |||
| 57 | $this->consoleStyle->warning("Invalid choice"); |
||
| 58 | } |
||
| 59 | while(true); |
||
| 60 | |||
| 61 | return $return; |
||
| 62 | } |
||
| 63 | } |
||
| 64 |