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 int $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 |
|
134 | |||
135 | /** |
||
136 | * Get array representation |
||
137 | * |
||
138 | * @return array |
||
139 | */ |
||
140 | 1 | public function toArray(): array |
|
144 | |||
145 | /** |
||
146 | * Get the first commit |
||
147 | * |
||
148 | * @return Commit|null |
||
149 | */ |
||
150 | public function first(): ?\GitElephant\Objects\Commit |
||
154 | |||
155 | /** |
||
156 | * Get the last commit |
||
157 | * |
||
158 | * @return Commit|null |
||
159 | */ |
||
160 | 3 | public function last(): ?\GitElephant\Objects\Commit |
|
164 | |||
165 | /** |
||
166 | * Get commit at index |
||
167 | * |
||
168 | * @param int $index the commit index |
||
169 | * |
||
170 | * @return Commit|null |
||
171 | */ |
||
172 | 1 | public function index(int $index): ?\GitElephant\Objects\Commit |
|
176 | |||
177 | /** |
||
178 | * ArrayAccess interface |
||
179 | * |
||
180 | * @param int $offset offset |
||
181 | * |
||
182 | * @return bool |
||
183 | */ |
||
184 | public function offsetExists($offset): bool |
||
188 | |||
189 | /** |
||
190 | * ArrayAccess interface |
||
191 | * |
||
192 | * @param int $offset offset |
||
193 | * |
||
194 | * @return Commit|null |
||
195 | */ |
||
196 | 14 | public function offsetGet($offset): ?\GitElephant\Objects\Commit |
|
200 | |||
201 | /** |
||
202 | * ArrayAccess interface |
||
203 | * |
||
204 | * @param int $offset offset |
||
205 | * @param mixed $value value |
||
206 | * |
||
207 | * @return void |
||
208 | * @throws \RuntimeException |
||
209 | */ |
||
210 | public function offsetSet($offset, $value) |
||
214 | |||
215 | /** |
||
216 | * ArrayAccess interface |
||
217 | * |
||
218 | * @param int $offset offset |
||
219 | * |
||
220 | * @return void |
||
221 | * @throws \RuntimeException |
||
222 | */ |
||
223 | public function offsetUnset($offset) |
||
227 | |||
228 | /** |
||
229 | * Countable interface |
||
230 | * |
||
231 | * @return int |
||
232 | */ |
||
233 | 8 | public function count(): int |
|
237 | |||
238 | /** |
||
239 | * Iterator interface |
||
240 | * |
||
241 | * @return Commit|null |
||
242 | */ |
||
243 | public function current(): ?\GitElephant\Objects\Commit |
||
247 | |||
248 | /** |
||
249 | * Iterator interface |
||
250 | */ |
||
251 | public function next(): void |
||
255 | |||
256 | /** |
||
257 | * Iterator interface |
||
258 | * |
||
259 | * @return int |
||
260 | */ |
||
261 | public function key(): int |
||
265 | |||
266 | /** |
||
267 | * Iterator interface |
||
268 | * |
||
269 | * @return bool |
||
270 | */ |
||
271 | public function valid(): bool |
||
275 | |||
276 | /** |
||
277 | * Iterator interface |
||
278 | */ |
||
279 | public function rewind(): void |
||
283 | |||
284 | /** |
||
285 | * Repository setter |
||
286 | * |
||
287 | * @param \GitElephant\Repository $repository the repository variable |
||
288 | */ |
||
289 | public function setRepository(Repository $repository): void |
||
293 | |||
294 | /** |
||
295 | * Repository getter |
||
296 | * |
||
297 | * @return \GitElephant\Repository |
||
298 | */ |
||
299 | 19 | public function getRepository(): \GitElephant\Repository |
|
303 | } |
||
304 |