1 | <?php |
||
28 | class LogRange implements \ArrayAccess, \Countable, \Iterator |
||
29 | { |
||
30 | /** |
||
31 | * @var \GitElephant\Repository |
||
32 | */ |
||
33 | private $repository; |
||
34 | |||
35 | /** |
||
36 | * the commits related to this log |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | private $rangeCommits = []; |
||
41 | |||
42 | /** |
||
43 | * the cursor position |
||
44 | * |
||
45 | * @var int |
||
46 | */ |
||
47 | private $position = 0; |
||
48 | |||
49 | /** |
||
50 | * Class constructor |
||
51 | * |
||
52 | * @param \GitElephant\Repository $repository repo |
||
53 | * @param string $refStart starting reference (excluded from the range) |
||
54 | * @param string $refEnd ending reference |
||
55 | * @param null $path path |
||
56 | * @param int $limit limit |
||
57 | * @param null $offset offset |
||
58 | * @param boolean $firstParent first parent |
||
59 | * |
||
60 | * @throws \RuntimeException |
||
61 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
62 | */ |
||
63 | 6 | public function __construct( |
|
76 | |||
77 | /** |
||
78 | * get the commit properties from command |
||
79 | * |
||
80 | * @param string $refStart treeish reference |
||
81 | * @param string $refEnd treeish reference |
||
82 | * @param string $path path |
||
83 | * @param int $limit limit |
||
84 | * @param string $offset offset |
||
85 | * @param boolean $firstParent first parent |
||
86 | * |
||
87 | * @throws \RuntimeException |
||
88 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
89 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
90 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
91 | * @see ShowCommand::commitInfo |
||
92 | */ |
||
93 | 6 | private function createFromCommand( |
|
118 | |||
119 | 6 | private function parseOutputLines(array $outputLines) |
|
137 | |||
138 | /** |
||
139 | * Get array representation |
||
140 | * |
||
141 | * @return array |
||
142 | */ |
||
143 | 1 | public function toArray() |
|
147 | |||
148 | /** |
||
149 | * Get the first commit |
||
150 | * |
||
151 | * @return Commit|null |
||
152 | */ |
||
153 | 1 | public function first() |
|
157 | |||
158 | /** |
||
159 | * Get the last commit |
||
160 | * |
||
161 | * @return Commit|null |
||
162 | */ |
||
163 | 1 | public function last() |
|
167 | |||
168 | /** |
||
169 | * Get commit at index |
||
170 | * |
||
171 | * @param int $index the commit index |
||
172 | * |
||
173 | * @return Commit|null |
||
174 | */ |
||
175 | 1 | public function index(int $index) |
|
179 | |||
180 | /** |
||
181 | * ArrayAccess interface |
||
182 | * |
||
183 | * @param int $offset offset |
||
184 | * |
||
185 | * @return bool |
||
186 | */ |
||
187 | 1 | public function offsetExists($offset) |
|
191 | |||
192 | /** |
||
193 | * ArrayAccess interface |
||
194 | * |
||
195 | * @param int $offset offset |
||
196 | * |
||
197 | * @return Commit|null |
||
198 | */ |
||
199 | 2 | public function offsetGet($offset) |
|
203 | |||
204 | /** |
||
205 | * ArrayAccess interface |
||
206 | * |
||
207 | * @param int $offset offset |
||
208 | * @param mixed $value value |
||
209 | * |
||
210 | * @throws \RuntimeException |
||
211 | */ |
||
212 | 1 | public function offsetSet($offset, $value) |
|
216 | |||
217 | /** |
||
218 | * ArrayAccess interface |
||
219 | * |
||
220 | * @param int $offset offset |
||
221 | * |
||
222 | * @throws \RuntimeException |
||
223 | */ |
||
224 | 1 | public function offsetUnset($offset) |
|
228 | |||
229 | /** |
||
230 | * Countable interface |
||
231 | * |
||
232 | * @return int|void |
||
233 | */ |
||
234 | 1 | public function count() |
|
238 | |||
239 | /** |
||
240 | * Iterator interface |
||
241 | * |
||
242 | * @return Commit|null |
||
243 | */ |
||
244 | 1 | public function current() |
|
248 | |||
249 | /** |
||
250 | * Iterator interface |
||
251 | */ |
||
252 | 1 | public function next() |
|
256 | |||
257 | /** |
||
258 | * Iterator interface |
||
259 | * |
||
260 | * @return int |
||
261 | */ |
||
262 | 1 | public function key() |
|
266 | |||
267 | /** |
||
268 | * Iterator interface |
||
269 | * |
||
270 | * @return bool |
||
271 | */ |
||
272 | 1 | public function valid() |
|
276 | |||
277 | /** |
||
278 | * Iterator interface |
||
279 | */ |
||
280 | 1 | public function rewind() |
|
284 | |||
285 | /** |
||
286 | * Repository setter |
||
287 | * |
||
288 | * @param \GitElephant\Repository $repository the repository variable |
||
289 | */ |
||
290 | 1 | public function setRepository(Repository $repository) |
|
294 | |||
295 | /** |
||
296 | * Repository getter |
||
297 | * |
||
298 | * @return \GitElephant\Repository |
||
299 | */ |
||
300 | 6 | public function getRepository() |
|
304 | } |
||
305 |