Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
SettingsFileUtils | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
resolveRelativeLocation | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Settings\Source; |
4 | |
5 | /** |
6 | * A collection of static utility methods for use with |
7 | * settings files. |
8 | * |
9 | * @since 1.38 |
10 | * @internal since the behavior may change to accommodate more types of source locations. |
11 | */ |
12 | class SettingsFileUtils { |
13 | |
14 | /** |
15 | * Resolves a relative settings source location. This method will attempt to interpret |
16 | * $path as relative to $base if possible. This behaves similar to relative URLs are |
17 | * made absolute using a base URL. |
18 | * |
19 | * The current implementation is based on file paths, but this may be expanded in the future |
20 | * to support other kinds of locations. |
21 | * |
22 | * @param string $path |
23 | * @param string $base |
24 | * |
25 | * @return string |
26 | */ |
27 | public static function resolveRelativeLocation( string $path, string $base ): string { |
28 | // Qualify the path if it isn't already absolute |
29 | if ( !preg_match( '!^[a-zA-Z]:\\\\!', $path ) && $path[0] != DIRECTORY_SEPARATOR ) { |
30 | $path = $base . DIRECTORY_SEPARATOR . $path; |
31 | } |
32 | |
33 | return $path; |
34 | } |
35 | } |