1 | <?php |
||
13 | final class GitBranches implements IteratorAggregate |
||
14 | { |
||
15 | /** |
||
16 | * @var GitWorkingCopy |
||
17 | */ |
||
18 | private $gitWorkingCopy; |
||
19 | |||
20 | public function __construct(GitWorkingCopy $gitWorkingCopy) |
||
21 | { |
||
22 | $this->gitWorkingCopy = clone $gitWorkingCopy; |
||
23 | $gitWorkingCopy->branch(['a' => true]); |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * Fetches the branches via the `git branch` command. |
||
28 | * |
||
29 | * @param bool $onlyRemote Whether to fetch only remote branches, defaults to false which returns all branches. |
||
30 | * @return string[] |
||
31 | */ |
||
32 | public function fetchBranches(bool $onlyRemote = false): array |
||
39 | |||
40 | public function trimBranch(string $branch): string |
||
44 | |||
45 | public function getIterator(): ArrayIterator |
||
50 | |||
51 | /** |
||
52 | * @return string[] |
||
53 | */ |
||
54 | public function all(): array |
||
58 | |||
59 | /** |
||
60 | * @return string[] |
||
61 | */ |
||
62 | public function remote(): array |
||
66 | |||
67 | /** |
||
68 | * Returns currently active branch (HEAD) of the working copy. |
||
69 | */ |
||
70 | public function head(): string |
||
74 | |||
75 | private function splitByNewline(string $string): array |
||
79 | } |
||
80 |