Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
MediaWikiVersionFetcher | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |
0.00% |
0 / 1 |
fetchVersion | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 |
1 | <?php |
2 | |
3 | /** |
4 | * Provides access to MediaWiki's version without requiring MediaWiki (or anything else) |
5 | * being loaded first. |
6 | * |
7 | * @deprecated since 1.42 |
8 | * |
9 | * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
10 | */ |
11 | class MediaWikiVersionFetcher { |
12 | |
13 | /** |
14 | * Get the MediaWiki version, extracted from the PHP source file where it is defined. |
15 | * |
16 | * @return string |
17 | * @throws RuntimeException |
18 | */ |
19 | public function fetchVersion() { |
20 | $code = file_get_contents( __DIR__ . '/../Defines.php' ); |
21 | |
22 | if ( !preg_match( "/define\( 'MW_VERSION', '([^']+)'/", $code, $matches ) ) { |
23 | throw new RuntimeException( 'Could not extract the MediaWiki version from Defines.php' ); |
24 | } |
25 | |
26 | return $matches[1]; |
27 | } |
28 | |
29 | } |