1 | <?php |
||
33 | class Log implements \ArrayAccess, \Countable, \Iterator |
||
34 | { |
||
35 | /** |
||
36 | * @var \GitElephant\Repository |
||
37 | */ |
||
38 | private $repository; |
||
39 | |||
40 | /** |
||
41 | * the commits related to this log |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | private $commits = []; |
||
46 | |||
47 | /** |
||
48 | * the cursor position |
||
49 | * |
||
50 | * @var int |
||
51 | */ |
||
52 | private $position = 0; |
||
53 | |||
54 | /** |
||
55 | * static method to generate standalone log |
||
56 | * |
||
57 | * @param \GitElephant\Repository $repository repo |
||
58 | * @param array $outputLines output lines from command.log |
||
59 | * |
||
60 | * @return \GitElephant\Objects\Log |
||
61 | */ |
||
62 | 1 | public static function createFromOutputLines(Repository $repository, array $outputLines): \GitElephant\Objects\Log |
|
69 | |||
70 | /** |
||
71 | * Class constructor |
||
72 | * |
||
73 | * @param Repository $repository |
||
74 | * @param string $ref |
||
75 | * @param string|null $path |
||
76 | * @param int $limit |
||
77 | * @param int|null $offset |
||
78 | * @param bool $firstParent |
||
79 | */ |
||
80 | 19 | public function __construct( |
|
91 | |||
92 | /** |
||
93 | * get the commit properties from command |
||
94 | * |
||
95 | * @param string $ref treeish reference |
||
96 | * @param string $path path |
||
97 | * @param int $limit limit |
||
98 | * @param string $offset offset |
||
99 | * @param boolean $firstParent first parent |
||
100 | * |
||
101 | * @throws \RuntimeException |
||
102 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
103 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
104 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
105 | * @see ShowCommand::commitInfo |
||
106 | */ |
||
107 | 19 | private function createFromCommand( |
|
124 | |||
125 | 19 | private function parseOutputLines(array $outputLines): void |
|
138 | |||
139 | /** |
||
140 | * Get array representation |
||
141 | * |
||
142 | * @return array |
||
143 | */ |
||
144 | 1 | public function toArray(): array |
|
148 | |||
149 | /** |
||
150 | * Get the first commit |
||
151 | * |
||
152 | * @return Commit|null |
||
153 | */ |
||
154 | public function first(): ?\GitElephant\Objects\Commit |
||
158 | |||
159 | /** |
||
160 | * Get the last commit |
||
161 | * |
||
162 | * @return Commit|null |
||
163 | */ |
||
164 | 3 | public function last(): ?\GitElephant\Objects\Commit |
|
168 | |||
169 | /** |
||
170 | * Get commit at index |
||
171 | * |
||
172 | * @param int $index the commit index |
||
173 | * |
||
174 | * @return Commit|null |
||
175 | */ |
||
176 | 1 | public function index(int $index): ?\GitElephant\Objects\Commit |
|
180 | |||
181 | /** |
||
182 | * ArrayAccess interface |
||
183 | * |
||
184 | * @param int $offset offset |
||
185 | * |
||
186 | * @return bool |
||
187 | */ |
||
188 | public function offsetExists($offset): bool |
||
192 | |||
193 | /** |
||
194 | * ArrayAccess interface |
||
195 | * |
||
196 | * @param int $offset offset |
||
197 | * |
||
198 | * @return Commit|null |
||
199 | */ |
||
200 | 14 | public function offsetGet($offset): ?\GitElephant\Objects\Commit |
|
204 | |||
205 | /** |
||
206 | * ArrayAccess interface |
||
207 | * |
||
208 | * @param int $offset offset |
||
209 | * @param mixed $value value |
||
210 | * |
||
211 | * @throws \RuntimeException |
||
212 | */ |
||
213 | public function offsetSet($offset, $value) |
||
217 | |||
218 | /** |
||
219 | * ArrayAccess interface |
||
220 | * |
||
221 | * @param int $offset offset |
||
222 | * |
||
223 | * @throws \RuntimeException |
||
224 | */ |
||
225 | public function offsetUnset($offset) |
||
229 | |||
230 | /** |
||
231 | * Countable interface |
||
232 | * |
||
233 | * @return int |
||
234 | */ |
||
235 | 8 | public function count(): int |
|
239 | |||
240 | /** |
||
241 | * Iterator interface |
||
242 | * |
||
243 | * @return Commit|null |
||
244 | */ |
||
245 | public function current(): ?\GitElephant\Objects\Commit |
||
249 | |||
250 | /** |
||
251 | * Iterator interface |
||
252 | */ |
||
253 | public function next(): void |
||
257 | |||
258 | /** |
||
259 | * Iterator interface |
||
260 | * |
||
261 | * @return int |
||
262 | */ |
||
263 | public function key(): int |
||
267 | |||
268 | /** |
||
269 | * Iterator interface |
||
270 | * |
||
271 | * @return bool |
||
272 | */ |
||
273 | public function valid(): bool |
||
277 | |||
278 | /** |
||
279 | * Iterator interface |
||
280 | */ |
||
281 | public function rewind(): void |
||
285 | |||
286 | /** |
||
287 | * Repository setter |
||
288 | * |
||
289 | * @param \GitElephant\Repository $repository the repository variable |
||
290 | */ |
||
291 | public function setRepository(Repository $repository): void |
||
295 | |||
296 | /** |
||
297 | * Repository getter |
||
298 | * |
||
299 | * @return \GitElephant\Repository |
||
300 | */ |
||
301 | 19 | public function getRepository(): \GitElephant\Repository |
|
305 | } |
||
306 |