1 | <?php |
||
18 | class Path |
||
19 | { |
||
20 | /** |
||
21 | * Path |
||
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 permanent |
||
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 | * Time for replacing placeholders |
||
57 | * |
||
58 | * @var int |
||
59 | */ |
||
60 | private $time; |
||
61 | |||
62 | /** |
||
63 | * Whether leading slash is needed or not |
||
64 | * |
||
65 | * @var bool |
||
66 | */ |
||
67 | private $leadingSlash; |
||
68 | |||
69 | /** |
||
70 | * Whether trailing slash is needed or not |
||
71 | * |
||
72 | * @var bool |
||
73 | */ |
||
74 | private $trailingSlash; |
||
75 | |||
76 | /** |
||
77 | * Path constructor. |
||
78 | * |
||
79 | * @param string $path |
||
80 | * @param int|null $time |
||
81 | * @param bool $leadingSlash |
||
82 | * @param bool $trailingSlash |
||
83 | */ |
||
84 | public function __construct(string $path, $time = null, $leadingSlash = true, $trailingSlash = false) |
||
93 | |||
94 | /** |
||
95 | * Updates path according to provided parameters. |
||
96 | */ |
||
97 | private function setUp() |
||
122 | |||
123 | /** |
||
124 | * Find path elements that can't change because of placeholder usage. |
||
125 | * |
||
126 | * @param string $path |
||
127 | */ |
||
128 | private function detectPathNotChanging(string $path) |
||
149 | |||
150 | /** |
||
151 | * Return path element at given index. |
||
152 | * |
||
153 | * @param int $index |
||
154 | * @return string |
||
155 | */ |
||
156 | public function getPathElementAtIndex(int $index) : string |
||
160 | |||
161 | /** |
||
162 | * Return the full target path depth. |
||
163 | * |
||
164 | * @return int |
||
165 | */ |
||
166 | public function getPathDepth() : int |
||
170 | |||
171 | /** |
||
172 | * Return the path to the backup file. |
||
173 | * |
||
174 | * @return string |
||
175 | */ |
||
176 | public function getPath() : string |
||
180 | |||
181 | /** |
||
182 | * Return the path to the backup file. |
||
183 | * |
||
184 | * @return string |
||
185 | */ |
||
186 | public function getPathRaw() : string |
||
190 | |||
191 | /** |
||
192 | * Is dirname configured with any date placeholders. |
||
193 | * |
||
194 | * @return bool |
||
195 | */ |
||
196 | public function hasChangingPath() : bool |
||
200 | |||
201 | /** |
||
202 | * Return the part of the path that is not changing. |
||
203 | * |
||
204 | * @return string |
||
205 | */ |
||
206 | public function getPathThatIsNotChanging() : string |
||
210 | |||
211 | /** |
||
212 | * Return path when casted to string. |
||
213 | * |
||
214 | * @return string |
||
215 | */ |
||
216 | public function __toString() |
||
220 | } |
||
221 |