1 | <?php |
||
10 | class GitIgnore |
||
11 | { |
||
12 | /** |
||
13 | * @var array |
||
14 | */ |
||
15 | protected $lines = array(); |
||
16 | |||
17 | /** |
||
18 | * @var string|null |
||
19 | */ |
||
20 | protected $gitIgnoreLocation; |
||
21 | |||
22 | /** |
||
23 | * @var bool |
||
24 | */ |
||
25 | protected $hasChanges = false; |
||
26 | |||
27 | /** |
||
28 | * @param string $fileLocation |
||
29 | */ |
||
30 | public function __construct($fileLocation) |
||
37 | |||
38 | /** |
||
39 | * @param string $file |
||
40 | */ |
||
41 | public function addEntry($file) |
||
49 | |||
50 | /** |
||
51 | * @param array $files |
||
52 | */ |
||
53 | public function addMultipleEntries(array $files) |
||
59 | |||
60 | /** |
||
61 | * @param string $file |
||
62 | */ |
||
63 | public function removeEntry($file) |
||
75 | |||
76 | /** |
||
77 | * @param array $files |
||
78 | */ |
||
79 | public function removeMultipleEntries(array $files) |
||
85 | |||
86 | /** |
||
87 | * @return array |
||
88 | */ |
||
89 | public function getEntries() |
||
93 | |||
94 | /** |
||
95 | * Write the file |
||
96 | */ |
||
97 | public function write() |
||
103 | |||
104 | /** |
||
105 | * Prepend a forward slash to a path |
||
106 | * if it does not already start with one. |
||
107 | * |
||
108 | * @param string $file |
||
109 | * @return string |
||
110 | */ |
||
111 | private function prependSlashIfNotExist($file) |
||
115 | |||
116 | /** |
||
117 | * Removes duplicate patterns from the input array, without touching comments, line breaks etc. |
||
118 | * Will remove the last duplicate pattern. |
||
119 | * |
||
120 | * @param array $lines |
||
121 | * @return array |
||
122 | */ |
||
123 | private function removeDuplicates($lines) |
||
155 | } |
||
156 |