1 | <?php |
||
28 | class StatusFile |
||
29 | { |
||
30 | public const UNTRACKED = '?'; |
||
31 | public const IGNORED = '!'; |
||
32 | public const UNMODIFIED = ''; |
||
33 | public const MODIFIED = 'M'; |
||
34 | public const ADDED = 'A'; |
||
35 | public const DELETED = 'D'; |
||
36 | public const RENAMED = 'R'; |
||
37 | public const COPIED = 'C'; |
||
38 | public const UPDATED_BUT_UNMERGED = 'U'; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | private $x; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | */ |
||
48 | private $y; |
||
49 | |||
50 | /** |
||
51 | * @var string |
||
52 | */ |
||
53 | private $name; |
||
54 | |||
55 | /** |
||
56 | * @var string |
||
57 | */ |
||
58 | private $renamed; |
||
59 | |||
60 | /** |
||
61 | * @var string |
||
62 | */ |
||
63 | private $type; |
||
64 | |||
65 | /** |
||
66 | * @var string |
||
67 | */ |
||
68 | private $description; |
||
69 | |||
70 | /** |
||
71 | * @param string $x X section of the status --porcelain output |
||
72 | * @param string $y Y section of the status --porcelain output |
||
73 | * @param string $name file name |
||
74 | * @param string $renamed new file name (if renamed) |
||
75 | */ |
||
76 | 9 | private function __construct(string $x, string $y, string $name, string $renamed = null) |
|
77 | { |
||
78 | 9 | $this->x = ' ' === $x ? null : $x; |
|
79 | 9 | $this->y = ' ' === $y ? null : $y; |
|
80 | 9 | $this->name = $name; |
|
81 | 9 | $this->renamed = $renamed; |
|
82 | 9 | } |
|
83 | |||
84 | /** |
||
85 | * @param string $x X section of the status --porcelain output |
||
86 | * @param string $y Y section of the status --porcelain output |
||
87 | * @param string $name file name |
||
88 | * @param string $renamed new file name (if renamed) |
||
89 | * |
||
90 | * @return StatusFile |
||
91 | */ |
||
92 | 9 | public static function create( |
|
100 | |||
101 | /** |
||
102 | * @return bool |
||
103 | */ |
||
104 | 5 | public function isRenamed(): bool |
|
108 | |||
109 | /** |
||
110 | * Get the file name |
||
111 | * |
||
112 | * @return string |
||
113 | */ |
||
114 | 1 | public function getName(): string |
|
115 | { |
||
116 | 1 | return $this->name; |
|
117 | } |
||
118 | |||
119 | /** |
||
120 | * Get the status of the index |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | 5 | public function getIndexStatus(): ?string |
|
128 | |||
129 | /** |
||
130 | * Get the status of the working tree |
||
131 | * |
||
132 | * @return string|null |
||
133 | */ |
||
134 | 6 | public function getWorkingTreeStatus(): ?string |
|
138 | |||
139 | /** |
||
140 | * description of the status |
||
141 | * |
||
142 | * @return void |
||
143 | */ |
||
144 | 1 | public function calculateDescription(): void |
|
176 | |||
177 | /** |
||
178 | * Set Description |
||
179 | * |
||
180 | * @param string $description the description variable |
||
181 | */ |
||
182 | 1 | public function setDescription(string $description): void |
|
186 | |||
187 | /** |
||
188 | * Get Description. |
||
189 | * Note that in certain environments, git might |
||
190 | * format the output differently, leading to the description |
||
191 | * being an empty string. Use setDescription(string) to set it yourself. |
||
192 | * |
||
193 | * @see #calulcateDescription() |
||
194 | * @see #setDescription($description) |
||
195 | * @return string |
||
196 | */ |
||
197 | 2 | public function getDescription(): string |
|
205 | |||
206 | /** |
||
207 | * Set Type |
||
208 | * |
||
209 | * @param string $type the type variable |
||
210 | */ |
||
211 | 1 | public function setType(string $type): void |
|
215 | |||
216 | /** |
||
217 | * Get the Type of status/change. |
||
218 | * Please note that this type might not be set by default. |
||
219 | * |
||
220 | * @return string |
||
221 | */ |
||
222 | 1 | public function getType(): ?string |
|
226 | } |
||
227 |