MergeConflict::getLocal()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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 MergeConflict
15
 *
16
 * This represents a merge conflict it includes the lines of the original and
17
 * both variations as well as the index on the original text where the conflict
18
 * starts.
19
 *
20
 * @package    PhpMerge
21
 * @author     Fabian Bircher <[email protected]>
22
 * @copyright  Fabian Bircher <[email protected]>
23
 * @license    https://opensource.org/licenses/MIT
24
 * @version    Release: @package_version@
25
 * @link       http://github.com/bircher/php-merge
26
 */
27
final class MergeConflict
28
{
29
30
    /**
31
     * The lines from the original.
32
     *
33
     * @var string[]
34
     */
35
    protected $base;
36
37
    /**
38
     * The conflicting line changes from the first source.
39
     *
40
     * @var string[]
41
     */
42
    protected $remote;
43
44
    /**
45
     * The conflicting line changes from the second source.
46
     *
47
     * @var string[]
48
     */
49
    protected $local;
50
51
    /**
52
     * The line number in the original text.
53
     *
54
     * @var int
55
     */
56
    protected $baseLine;
57
58
    /**
59
     * The line number in the merged text.
60
     *
61
     * @var int
62
     */
63
    protected $mergedLine;
64
65
    /**
66
     * MergeConflict constructor.
67
     *
68
     * @param string[] $base
69
     *   The original lines where the conflict happened.
70
     * @param string[] $remote
71
     *   The conflicting line changes from the first source.
72
     * @param string[] $local
73
     *   The conflicting line changes from the second source.
74
     * @param int $baseLine
75
     *   The line number in the original text.
76
     * @param int $mergedLine
77
     *   The line number in the merged text.
78
     */
79 10
    public function __construct($base, $remote, $local, $baseLine, $mergedLine)
80
    {
81 10
        $this->base = $base;
82 10
        $this->remote = $remote;
83 10
        $this->local = $local;
84 10
        $this->baseLine = $baseLine;
85 10
        $this->mergedLine = $mergedLine;
86 10
    }
87
88
    /**
89
     * Get the base text of the conflict.
90
     *
91
     * @return string[]
92
     *   The array of lines which are involved in the conflict.
93
     */
94 6
    public function getBase()
95
    {
96 6
        return $this->base;
97
    }
98
99
    /**
100
     * Get the lines from the first text.
101
     *
102
     * @return string[]
103
     *   The array of lines from the first text involved in the conflict.
104
     */
105 3
    public function getRemote()
106
    {
107 3
        return $this->remote;
108
    }
109
110
    /**
111
     * Get the lines from the second text.
112
     *
113
     * @return string[]
114
     *   The array of lines from the first text involved in the conflict.
115
     */
116 3
    public function getLocal()
117
    {
118 3
        return $this->local;
119
    }
120
121
    /**
122
     * Get the line number in the original text where the conflict starts.
123
     *
124
     * @return int
125
     *   The line number as in the original text.
126
     */
127 6
    public function getBaseLine()
128
    {
129 6
        return $this->baseLine;
130
    }
131
132
    /**
133
     * Get the line number in the merged text where the conflict starts.
134
     *
135
     * @return int
136
     *   The line number in the merged text.
137
     */
138 3
    public function getMergedLine()
139
    {
140 3
        return $this->mergedLine;
141
    }
142
}
143