Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
PHPVariableLoader | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
loadVariableFromPHPFile | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace MediaWiki\Extension\Translate\Utilities; |
5 | |
6 | /** |
7 | * Stuff for handling configuration files in PHP format. |
8 | * |
9 | * @author Niklas Laxström |
10 | * @copyright Copyright © 2010 Niklas Laxström |
11 | * @license GPL-2.0-or-later |
12 | */ |
13 | |
14 | class PHPVariableLoader { |
15 | /** |
16 | * Returns a global variable from PHP file by executing the file. |
17 | * @param string $_filename Path to the file. |
18 | * @param string $_variable Name of the variable. |
19 | * @return mixed|null The variable contents or null. |
20 | */ |
21 | public static function loadVariableFromPHPFile( string $_filename, string $_variable ) { |
22 | if ( !file_exists( $_filename ) ) { |
23 | return null; |
24 | } else { |
25 | require $_filename; |
26 | |
27 | return $$_variable ?? null; |
28 | } |
29 | } |
30 | } |