1 | <?php |
||
32 | class Status |
||
33 | { |
||
34 | /** |
||
35 | * @var \GitElephant\Repository |
||
36 | */ |
||
37 | private $repository; |
||
38 | |||
39 | /** |
||
40 | * @var array<StatusFile> |
||
41 | */ |
||
42 | protected $files; |
||
43 | |||
44 | /** |
||
45 | * Private constructor in order to follow the singleton pattern |
||
46 | * |
||
47 | * @param Repository $repository |
||
48 | * |
||
49 | * @throws \RuntimeException |
||
50 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
51 | */ |
||
52 | 10 | private function __construct(Repository $repository) |
|
58 | |||
59 | /** |
||
60 | * @param Repository $repository |
||
61 | * |
||
62 | * @return \GitElephant\Status\Status |
||
63 | */ |
||
64 | 10 | public static function get(Repository $repository) |
|
68 | |||
69 | /** |
||
70 | * create from git command |
||
71 | */ |
||
72 | 10 | private function createFromCommand(): void |
|
78 | |||
79 | /** |
||
80 | * all files |
||
81 | * |
||
82 | * @return Sequence<StatusFile> |
||
|
|||
83 | */ |
||
84 | 1 | public function all(): \PhpCollection\Sequence |
|
85 | { |
||
86 | 1 | return new Sequence($this->files); |
|
87 | } |
||
88 | |||
89 | /** |
||
90 | * untracked files |
||
91 | * |
||
92 | * @return Sequence<StatusFile> |
||
93 | */ |
||
94 | 2 | public function untracked(): \PhpCollection\Sequence |
|
98 | |||
99 | /** |
||
100 | * modified files |
||
101 | * |
||
102 | * @return Sequence<StatusFile> |
||
103 | */ |
||
104 | 2 | public function modified(): \PhpCollection\Sequence |
|
108 | |||
109 | /** |
||
110 | * added files |
||
111 | * |
||
112 | * @return Sequence<StatusFile> |
||
113 | */ |
||
114 | 4 | public function added(): \PhpCollection\Sequence |
|
118 | |||
119 | /** |
||
120 | * deleted files |
||
121 | * |
||
122 | * @return Sequence<StatusFile> |
||
123 | */ |
||
124 | 2 | public function deleted(): \PhpCollection\Sequence |
|
128 | |||
129 | /** |
||
130 | * renamed files |
||
131 | * |
||
132 | * @return Sequence<StatusFile> |
||
133 | */ |
||
134 | 1 | public function renamed(): \PhpCollection\Sequence |
|
138 | |||
139 | /** |
||
140 | * copied files |
||
141 | * |
||
142 | * @return Sequence<StatusFile> |
||
143 | */ |
||
144 | public function copied(): \PhpCollection\Sequence |
||
148 | |||
149 | /** |
||
150 | * create objects from command output |
||
151 | * https://www.kernel.org/pub/software/scm/git/docs/git-status.html in the output section |
||
152 | * |
||
153 | * |
||
154 | * @param array $lines |
||
155 | */ |
||
156 | 10 | private function parseOutputLines(array $lines): void |
|
167 | |||
168 | /** |
||
169 | * @param string $line |
||
170 | * |
||
171 | * @return array<string>|null |
||
172 | */ |
||
173 | protected function splitStatusLine(string $line) |
||
179 | |||
180 | /** |
||
181 | * filter files status in working tree and in index status |
||
182 | * |
||
183 | * @param string $type |
||
184 | * |
||
185 | * @return Sequence<StatusFile> |
||
186 | */ |
||
187 | 5 | protected function filterByType(string $type): \PhpCollection\Sequence |
|
202 | } |
||
203 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.