1 | <?php |
||
18 | class Path |
||
19 | { |
||
20 | /** |
||
21 | * Path without trailing slashes. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | private $path; |
||
26 | |||
27 | /** |
||
28 | * Raw path, that could contain placeholders. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | private $pathRaw; |
||
33 | |||
34 | /** |
||
35 | * Part of path, that is not changing because of placeholders. |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | private $pathNotChanging; |
||
40 | |||
41 | /** |
||
42 | * Indicates if the path changes over time. |
||
43 | * |
||
44 | * @var bool |
||
45 | */ |
||
46 | private $pathIsChanging = false; |
||
47 | |||
48 | /** |
||
49 | * List of all path elements. |
||
50 | * |
||
51 | * @var string[] |
||
52 | */ |
||
53 | private $pathElements = []; |
||
54 | |||
55 | /** |
||
56 | * List of not changing path elements. |
||
57 | * |
||
58 | * @var string[] |
||
59 | */ |
||
60 | private $pathElementsNotChanging = []; |
||
61 | |||
62 | /** |
||
63 | * Time for replacing placeholders |
||
64 | * |
||
65 | * @var int |
||
66 | */ |
||
67 | private $time; |
||
68 | |||
69 | /** |
||
70 | * Whether leading slash is needed or not |
||
71 | * |
||
72 | * @var bool |
||
73 | */ |
||
74 | private $isAbsolute; |
||
75 | 53 | ||
76 | /** |
||
77 | 53 | * Path constructor. |
|
78 | 53 | * |
|
79 | * @param string $path |
||
80 | 53 | * @param int|null $time |
|
81 | 53 | */ |
|
82 | public function __construct(string $path, $time = null) |
||
89 | |||
90 | 53 | /** |
|
91 | 53 | * Setup path |
|
92 | 53 | * |
|
93 | * @param string $path |
||
94 | */ |
||
95 | private function setupPath(string $path) |
||
109 | 11 | ||
110 | /** |
||
111 | 11 | * Find path elements that can't change because of placeholder usage. |
|
112 | 11 | * |
|
113 | * @return void |
||
114 | 11 | */ |
|
115 | 11 | private function handleChangingPath() |
|
138 | |||
139 | /** |
||
140 | * Return path element at given index. |
||
141 | 6 | * |
|
142 | * @param int $index |
||
143 | 6 | * @return string |
|
144 | */ |
||
145 | public function getPathElementAtIndex(int $index): string |
||
149 | |||
150 | /** |
||
151 | 11 | * Return the full target path depth. |
|
152 | * |
||
153 | 11 | * @return int |
|
154 | */ |
||
155 | public function getPathDepth(): int |
||
159 | |||
160 | /** |
||
161 | 26 | * Return depth of path that is not changing. |
|
162 | * |
||
163 | 26 | * @return int |
|
164 | */ |
||
165 | public function getPathThatIsNotChangingDepth(): int |
||
169 | |||
170 | /** |
||
171 | 4 | * Return the path to the backup file. |
|
172 | * |
||
173 | 4 | * @return string |
|
174 | */ |
||
175 | public function getPath(): string |
||
179 | |||
180 | /** |
||
181 | 3 | * Return the path to the backup file. |
|
182 | * |
||
183 | 3 | * @return string |
|
184 | */ |
||
185 | public function getPathRaw(): string |
||
189 | |||
190 | /** |
||
191 | 13 | * Is dirname configured with any date placeholders. |
|
192 | * |
||
193 | 13 | * @return bool |
|
194 | */ |
||
195 | public function hasChangingPath(): bool |
||
199 | |||
200 | /** |
||
201 | 2 | * Return the part of the path that is not changing. |
|
202 | * |
||
203 | 2 | * @return string |
|
204 | */ |
||
205 | public function getPathThatIsNotChanging(): string |
||
209 | |||
210 | /** |
||
211 | * Return path when casted to string. |
||
212 | * |
||
213 | * @return string |
||
214 | */ |
||
215 | public function __toString() |
||
219 | } |
||
220 |