1 | <?php |
||
31 | class Status |
||
32 | { |
||
33 | /** |
||
34 | * @var \GitElephant\Repository |
||
35 | */ |
||
36 | private $repository; |
||
37 | |||
38 | /** |
||
39 | * @var array |
||
40 | */ |
||
41 | protected $files; |
||
42 | |||
43 | /** |
||
44 | * @param Repository $repository |
||
45 | * |
||
46 | * @throws \RuntimeException |
||
47 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
48 | */ |
||
49 | 9 | private function __construct(Repository $repository) |
|
55 | |||
56 | /** |
||
57 | * @param Repository $repository |
||
58 | * |
||
59 | * @return \GitElephant\Status\Status |
||
60 | */ |
||
61 | 9 | public static function get(Repository $repository) |
|
65 | |||
66 | /** |
||
67 | * create from git command |
||
68 | */ |
||
69 | 9 | private function createFromCommand() |
|
75 | |||
76 | /** |
||
77 | * all files |
||
78 | * |
||
79 | * @return Sequence |
||
80 | */ |
||
81 | public function all() |
||
85 | |||
86 | /** |
||
87 | * untracked files |
||
88 | * |
||
89 | * @return Sequence |
||
90 | */ |
||
91 | 2 | public function untracked() |
|
95 | |||
96 | /** |
||
97 | * modified files |
||
98 | * |
||
99 | * @return Sequence |
||
100 | */ |
||
101 | 2 | public function modified() |
|
105 | |||
106 | /** |
||
107 | * added files |
||
108 | * |
||
109 | * @return Sequence |
||
110 | */ |
||
111 | 4 | public function added() |
|
115 | |||
116 | /** |
||
117 | * deleted files |
||
118 | * |
||
119 | * @return Sequence |
||
120 | */ |
||
121 | 2 | public function deleted() |
|
125 | |||
126 | /** |
||
127 | * renamed files |
||
128 | * |
||
129 | * @return Sequence |
||
130 | */ |
||
131 | 1 | public function renamed() |
|
135 | |||
136 | /** |
||
137 | * copied files |
||
138 | * |
||
139 | * @return Sequence |
||
140 | */ |
||
141 | public function copied() |
||
145 | |||
146 | /** |
||
147 | * create objects from command output |
||
148 | * https://www.kernel.org/pub/software/scm/git/docs/git-status.html in the output section |
||
149 | * |
||
150 | * |
||
151 | * @param array $lines |
||
152 | */ |
||
153 | 9 | private function parseOutputLines(array $lines) |
|
164 | |||
165 | /** |
||
166 | * @param string $line |
||
167 | * |
||
168 | * @return mixed |
||
169 | */ |
||
170 | protected function splitStatusLine(string $line) |
||
176 | |||
177 | /** |
||
178 | * filter files status in working tree and in index status |
||
179 | * |
||
180 | * @param string $type |
||
181 | * |
||
182 | * @return Sequence |
||
183 | */ |
||
184 | 5 | protected function filterByType(string $type) |
|
199 | } |
||
200 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.