Base.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Copyright 2007-2012 Horde LLC (http://www.horde.org/)
  4. *
  5. * See the enclosed file COPYING for license information (LGPL). If you did
  6. * not receive this file, see http://www.horde.org/licenses/lgpl21.
  7. *
  8. * @package Text_Diff
  9. * @author Geoffrey T. Dairiki <dairiki@dairiki.org>
  10. */
  11. class Horde_Text_Diff_ThreeWay_Op_Base
  12. {
  13. public function __construct($orig = false, $final1 = false, $final2 = false)
  14. {
  15. $this->orig = $orig ? $orig : [];
  16. $this->final1 = $final1 ? $final1 : [];
  17. $this->final2 = $final2 ? $final2 : [];
  18. }
  19. public function merged()
  20. {
  21. if (!isset($this->_merged)) {
  22. if ($this->final1 === $this->final2) {
  23. $this->_merged = &$this->final1;
  24. } elseif ($this->final1 === $this->orig) {
  25. $this->_merged = &$this->final2;
  26. } elseif ($this->final2 === $this->orig) {
  27. $this->_merged = &$this->final1;
  28. } else {
  29. $this->_merged = false;
  30. }
  31. }
  32. return $this->_merged;
  33. }
  34. public function isConflict()
  35. {
  36. return $this->merged() === false;
  37. }
  38. }