1 | <?php |
||
34 | class Diff implements \ArrayAccess, \Countable, \Iterator |
||
35 | { |
||
36 | /** |
||
37 | * @var \GitElephant\Repository |
||
38 | */ |
||
39 | private $repository; |
||
40 | |||
41 | /** |
||
42 | * the cursor position |
||
43 | * |
||
44 | * @var int |
||
45 | */ |
||
46 | private $position; |
||
47 | |||
48 | /** |
||
49 | * DiffObject instances |
||
50 | * |
||
51 | * @var array<DiffObject> |
||
52 | */ |
||
53 | private $diffObjects = []; |
||
54 | |||
55 | /** |
||
56 | * static generator to generate a Diff object |
||
57 | * |
||
58 | * @param \GitElephant\Repository $repository repository |
||
59 | * @param null|string|\GitElephant\Objects\Commit $commit1 first commit |
||
60 | * @param null|string|\GitElephant\Objects\Commit $commit2 second commit |
||
61 | * @param null|string $path path to consider |
||
62 | * |
||
63 | * @throws \RuntimeException |
||
64 | * @throws \InvalidArgumentException |
||
65 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
66 | * @return Diff |
||
67 | */ |
||
68 | 2 | public static function create( |
|
79 | |||
80 | /** |
||
81 | * Class constructor |
||
82 | * bare Diff object |
||
83 | * |
||
84 | * @param \GitElephant\Repository $repository repository instance |
||
85 | * @param array<DiffObject> $diffObjects array of diff objects |
||
86 | */ |
||
87 | 2 | public function __construct(Repository $repository, array $diffObjects = []) |
|
93 | |||
94 | /** |
||
95 | * get the commit properties from command |
||
96 | * |
||
97 | * @param string|null$commit1 commit 1 |
||
98 | * @param string|null$commit2 commit 2 |
||
99 | * @param string|null$path path |
||
100 | * |
||
101 | * @throws \RuntimeException |
||
102 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
103 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
104 | * @throws \InvalidArgumentException |
||
105 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
106 | * @see ShowCommand::commitInfo |
||
107 | */ |
||
108 | 2 | public function createFromCommand($commit1 = null, $commit2 = null, $path = null): void |
|
134 | |||
135 | /** |
||
136 | * parse the output of a git command showing a commit |
||
137 | * |
||
138 | * @param array $outputLines output lines |
||
139 | * |
||
140 | * @throws \InvalidArgumentException |
||
141 | */ |
||
142 | 2 | private function parseOutputLines(array $outputLines): void |
|
151 | |||
152 | /** |
||
153 | * @return \GitElephant\Command\Caller\CallerInterface |
||
154 | */ |
||
155 | 2 | private function getCaller(): CallerInterface |
|
159 | |||
160 | /** |
||
161 | * Repository setter |
||
162 | * |
||
163 | * @param \GitElephant\Repository $repository the repository variable |
||
164 | */ |
||
165 | public function setRepository(Repository $repository): void |
||
169 | |||
170 | /** |
||
171 | * Repository getter |
||
172 | * |
||
173 | * @return \GitElephant\Repository |
||
174 | */ |
||
175 | 2 | public function getRepository(): \GitElephant\Repository |
|
179 | |||
180 | /** |
||
181 | * ArrayAccess interface |
||
182 | * |
||
183 | * @param int $offset offset |
||
184 | * |
||
185 | * @return bool |
||
186 | */ |
||
187 | public function offsetExists($offset): bool |
||
191 | |||
192 | /** |
||
193 | * ArrayAccess interface |
||
194 | * |
||
195 | * @param int $offset offset |
||
196 | * |
||
197 | * @return null|mixed |
||
198 | */ |
||
199 | 1 | public function offsetGet($offset) |
|
203 | |||
204 | /** |
||
205 | * ArrayAccess interface |
||
206 | * |
||
207 | * @param int|null $offset offset |
||
208 | * @param mixed $value value |
||
209 | */ |
||
210 | public function offsetSet($offset, $value): void |
||
218 | |||
219 | /** |
||
220 | * ArrayAccess interface |
||
221 | * |
||
222 | * @param int $offset offset |
||
223 | */ |
||
224 | public function offsetUnset($offset): void |
||
228 | |||
229 | /** |
||
230 | * Countable interface |
||
231 | * |
||
232 | * @return int |
||
233 | */ |
||
234 | 2 | public function count(): int |
|
238 | |||
239 | /** |
||
240 | * Iterator interface |
||
241 | * |
||
242 | * @return mixed |
||
243 | */ |
||
244 | public function current() |
||
248 | |||
249 | /** |
||
250 | * Iterator interface |
||
251 | */ |
||
252 | public function next(): void |
||
256 | |||
257 | /** |
||
258 | * Iterator interface |
||
259 | * |
||
260 | * @return int |
||
261 | */ |
||
262 | public function key(): int |
||
266 | |||
267 | /** |
||
268 | * Iterator interface |
||
269 | * |
||
270 | * @return bool |
||
271 | */ |
||
272 | public function valid(): bool |
||
276 | |||
277 | /** |
||
278 | * Iterator interface |
||
279 | */ |
||
280 | public function rewind(): void |
||
284 | } |
||
285 |