1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the php-merge package. |
4
|
|
|
* |
5
|
|
|
* (c) Fabian Bircher <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace PhpMerge; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class MergeException |
15
|
|
|
* |
16
|
|
|
* A merge exception thrown when a merge conflict occurs, catch it to get both |
17
|
|
|
* the array of conflicts and a merged version of the text when the conflicts |
18
|
|
|
* have been resolved by using the first variation. |
19
|
|
|
* |
20
|
|
|
* @package PhpMerge |
21
|
|
|
* @author Fabian Bircher <[email protected]> |
22
|
|
|
* @copyright Fabian Bircher <[email protected]> |
23
|
|
|
* @license https://opensource.org/licenses/MITe |
24
|
|
|
* @version Release: @package_version@ |
25
|
|
|
* @link http://github.com/bircher/php-merge |
26
|
|
|
*/ |
27
|
|
|
final class MergeException extends \RuntimeException |
28
|
|
|
{ |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var \PhpMerge\MergeConflict[] |
32
|
|
|
*/ |
33
|
|
|
protected $conflicts; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
protected $merged; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* MergeException constructor. |
42
|
|
|
* |
43
|
|
|
* @param string $message |
44
|
|
|
* The Exception message to throw. |
45
|
|
|
* @param \PhpMerge\MergeConflict[] $conflicts |
46
|
|
|
* The array of merge conflicts that occured. |
47
|
|
|
* @param string $merged |
48
|
|
|
* The merged string using remote to resolve the conflicts. |
49
|
|
|
* @param int $code |
50
|
|
|
* The Exception code. |
51
|
|
|
* @param \Exception $previous |
52
|
|
|
* The previous exception used for the exception chaining. |
53
|
|
|
*/ |
54
|
10 |
|
public function __construct($message = "", $conflicts = [], $merged = null, $code = 0, \Exception $previous = null) |
55
|
|
|
{ |
56
|
10 |
|
parent::__construct($message, $code, $previous); |
57
|
10 |
|
$this->conflicts = $conflicts; |
58
|
10 |
|
$this->merged = $merged; |
59
|
10 |
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Get the merge conflicts associated with the exception. |
63
|
|
|
* |
64
|
|
|
* @return \PhpMerge\MergeConflict[] |
65
|
|
|
* All the conflicts that happened during the merge. |
66
|
|
|
*/ |
67
|
10 |
|
public function getConflicts() |
68
|
|
|
{ |
69
|
10 |
|
return $this->conflicts; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Get the merged text if the first text is used to resolve the conflict. |
74
|
|
|
* |
75
|
|
|
* @return string |
76
|
|
|
* The merged text. |
77
|
|
|
*/ |
78
|
8 |
|
public function getMerged() : string |
79
|
|
|
{ |
80
|
8 |
|
return $this->merged; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|