1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* GitElephant - An abstraction layer for git written in PHP |
5
|
|
|
* Copyright (C) 2013 Matteo Giachino |
6
|
|
|
* |
7
|
|
|
* This program is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU General Public License as published by |
9
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
10
|
|
|
* (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU General Public License |
18
|
|
|
* along with this program. If not, see [http://www.gnu.org/licenses/]. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace GitElephant\Status; |
22
|
|
|
|
23
|
|
|
use PhpCollection\Sequence; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Class StatusIndex |
27
|
|
|
* |
28
|
|
|
* @package GitElephant\Status |
29
|
|
|
*/ |
30
|
|
|
class StatusIndex extends Status |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* @return Sequence<StatusFile> |
|
|
|
|
34
|
|
|
*/ |
35
|
1 |
|
public function untracked(): \PhpCollection\Sequence |
36
|
|
|
{ |
37
|
1 |
|
return new Sequence(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* all files with modified status in the index |
42
|
|
|
* |
43
|
|
|
* @return Sequence<StatusFile> |
|
|
|
|
44
|
|
|
*/ |
45
|
2 |
|
public function all(): \PhpCollection\Sequence |
46
|
|
|
{ |
47
|
2 |
|
return new Sequence( |
48
|
2 |
|
array_filter( |
49
|
2 |
|
$this->files, |
50
|
|
|
function (StatusFile $statusFile) { |
51
|
2 |
|
return $statusFile->getIndexStatus() && '?' !== $statusFile->getIndexStatus(); |
52
|
2 |
|
} |
53
|
|
|
) |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* filter files by index status |
59
|
|
|
* |
60
|
|
|
* @param string $type |
61
|
|
|
* |
62
|
|
|
* @return Sequence<StatusFile> |
|
|
|
|
63
|
|
|
*/ |
64
|
3 |
|
protected function filterByType(string $type): \PhpCollection\Sequence |
65
|
|
|
{ |
66
|
3 |
|
if (!$this->files) { |
|
|
|
|
67
|
1 |
|
return new Sequence(); |
68
|
|
|
} |
69
|
|
|
|
70
|
2 |
|
return new Sequence( |
71
|
2 |
|
array_filter( |
72
|
2 |
|
$this->files, |
73
|
|
|
function (StatusFile $statusFile) use ($type) { |
74
|
2 |
|
return $type === $statusFile->getIndexStatus(); |
75
|
2 |
|
} |
76
|
|
|
) |
77
|
|
|
); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
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.